Skip to content

Commit 404525b

Browse files
authored
docs: Initial javadocs for our logging annotation. (#40)
1 parent e1dcfa6 commit 404525b

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

src/main/java/software/amazon/lambda/logging/PowerToolsLogging.java

+37
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,43 @@
55
import java.lang.annotation.RetentionPolicy;
66
import java.lang.annotation.Target;
77

8+
/**
9+
* {@code PowerToolsLogging} is used to signal that the annotated method should be
10+
* extended with PowerToolsLogging functionality.
11+
*
12+
* <p>{@code PowerToolsLogging} provides an opinionated logger with output structured as JSON.</p>
13+
*
14+
* <p>{@code PowerToolsLogging} should be used with handleRequest method of a class
15+
* which implements either
16+
* {@code com.amazonaws.services.lambda.runtime.RequestHandler} or
17+
* {@code com.amazonaws.services.lambda.runtime.RequestStreamHandler}.</p>
18+
*
19+
* <p>By default {@code PowerToolsLogging} will load the following keys and values from the Lambda
20+
* {@code com.amazonaws.services.lambda.runtime.Context}</p>
21+
*
22+
* <ul>
23+
* <li>FunctionName</li>
24+
* <li>FunctionVersion</li>
25+
* <li>InvokedFunctionArn</li>
26+
* <li>MemoryLimitInMB</li>
27+
* </ul>
28+
*
29+
* <p>By default {@code PowerToolsLogging} will also create keys for:</p>
30+
*
31+
* <ul>
32+
* <li>coldStart - True if this is the first invocation of this Lambda execution environment; else False</li>
33+
* <li>service - The value of the 'POWER_TOOLS_SERVICE_NAME' environment variable or 'service_undefined'</li>
34+
* </ul>
35+
*
36+
* <p>These keys and values will be joined with the existing Log4J log event and written as JSON.</p>
37+
*
38+
* <p>The data and time of the log event will be written using {@link java.time.format.DateTimeFormatter#ISO_ZONED_DATE_TIME}</p>
39+
*
40+
* <p>By default {@code PowerToolsLogging} will not log the event which has trigger the invoke of the Lambda function.
41+
* This can be enabled using {@code @PowerToolsLogging(logEvent = true)}.</p>
42+
*
43+
* <p>To append additional keys to each log entry you can use {@link software.amazon.lambda.logging.PowerLogger#customKey(String, String)}</p>
44+
*/
845
@Retention(RetentionPolicy.RUNTIME)
946
@Target(ElementType.METHOD)
1047
public @interface PowerToolsLogging {

0 commit comments

Comments
 (0)