|
5 | 5 | import java.lang.annotation.RetentionPolicy;
|
6 | 6 | import java.lang.annotation.Target;
|
7 | 7 |
|
| 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 | + */ |
8 | 45 | @Retention(RetentionPolicy.RUNTIME)
|
9 | 46 | @Target(ElementType.METHOD)
|
10 | 47 | public @interface PowerToolsLogging {
|
|
0 commit comments