From b5f4fccfa504fefb17dfa3028e4949339b02b9d7 Mon Sep 17 00:00:00 2001
From: msailes
Date: Tue, 18 Aug 2020 14:57:31 +0100
Subject: [PATCH 1/2] docs: Initial javadocs for our logging annotation.
---
.../lambda/logging/PowerToolsLogging.java | 37 +++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/src/main/java/software/amazon/lambda/logging/PowerToolsLogging.java b/src/main/java/software/amazon/lambda/logging/PowerToolsLogging.java
index 98ade6924..d21e4d583 100644
--- a/src/main/java/software/amazon/lambda/logging/PowerToolsLogging.java
+++ b/src/main/java/software/amazon/lambda/logging/PowerToolsLogging.java
@@ -5,6 +5,43 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
+/**
+ * {@code PowerToolsLogging} is used to signal that the annotated method should be
+ * extended with PowerToolsLogging functionality.
+ *
+ *
{@code PowerToolsLogging} provides an opinionated logger with output structured as JSON.
+ *
+ *
{@code PowerToolsLogging} should be used with handleRequest method of a class
+ * which implements either
+ * {@code com.amazonaws.services.lambda.runtime.RequestHandler} or
+ * {@code com.amazonaws.services.lambda.runtime.RequestStreamHandler}.
+ *
+ *
By default {@code PowerToolsLogging} will load the following keys and values from the Lambda
+ * {@code com.amazonaws.services.lambda.runtime.Context}
+ *
+ *
+ *
FunctionName
+ *
FunctionVersion
+ *
InvokedFunctionArn
+ *
MemoryLimitInMB
+ *
+ *
+ *
By default {@code PowerToolsLogging} will also create keys for:
+ *
+ *
+ *
coldStart - True if this is the first invocation of this Lambda execution environment; else False
+ *
service - The value of the 'POWER_TOOLS_SERVICE_NAME' environment variable or 'service_undefined'
+ *
+ *
+ *
These keys and values will be joined with the existing Log4J log event and written as JSON.
+ *
+ *
The data and time of the log event will be written using {@link java.time.format.DateTimeFormatter#ISO_ZONED_DATE_TIME}
+ *
+ *
By default {@code PowerToolsLogging} will not log the event which has trigger the invoke of the Lambda function.
+ * This can be enabled using {@code @PowerToolsLogging(logEvent = true)}.
+ *
+ *
To append additional keys to each log entry you can use {@link software.amazon.lambda.logging.PowerLogger#customKey(String, String)}
+ */
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface PowerToolsLogging {
From e427fed85e2039cfdcfae7a73aa14fa6e5d9dfab Mon Sep 17 00:00:00 2001
From: msailes
Date: Wed, 19 Aug 2020 13:05:12 +0100
Subject: [PATCH 2/2] docs: Initial javadocs for PowerLogger class.
---
docs/content/core/logger.mdx | 4 ++--
.../src/main/java/helloworld/App.java | 2 +-
.../amazon/lambda/logging/PowerLogger.java | 14 +++++++++++++-
.../amazon/lambda/logging/PowerToolsLogging.java | 2 +-
.../log4j/core/layout/LambdaJsonLayoutTest.java | 2 +-
.../amazon/lambda/logging/PowerLoggerTest.java | 2 +-
6 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/docs/content/core/logger.mdx b/docs/content/core/logger.mdx
index c9e33c68b..7cd21c5d4 100644
--- a/docs/content/core/logger.mdx
+++ b/docs/content/core/logger.mdx
@@ -114,7 +114,7 @@ public class App implements RequestHandlerBy default {@code PowerToolsLogging} will not log the event which has trigger the invoke of the Lambda function.
* This can be enabled using {@code @PowerToolsLogging(logEvent = true)}.
*
- *
To append additional keys to each log entry you can use {@link software.amazon.lambda.logging.PowerLogger#customKey(String, String)}
+ *
To append additional keys to each log entry you can use {@link software.amazon.lambda.logging.PowerLogger#appendKey(String, String)}