Skip to content

Commit a02fa51

Browse files
committed
Update documentation for aspectJ
1 parent 66cac4d commit a02fa51

11 files changed

+1050
-123
lines changed

docs/core/logging.md

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,141 @@ Logging provides an opinionated logger with output structured as JSON.
1111
* Log Lambda event when instructed, disabled by default, can be enabled explicitly via annotation param
1212
* Append additional keys to structured log at any point in time
1313

14+
## Install
15+
16+
Depending on your version of Java (either Java 1.8 or 11+), the configuration slightly changes.
17+
18+
=== "Maven Java 11+"
19+
20+
```xml hl_lines="3-7 16 18 24-27"
21+
<dependencies>
22+
...
23+
<dependency>
24+
<groupId>software.amazon.lambda</groupId>
25+
<artifactId>powertools-logging</artifactId>
26+
<version>{{ powertools.version }}</version>
27+
</dependency>
28+
...
29+
</dependencies>
30+
...
31+
<!-- configure the aspectj-maven-plugin to compile-time weave (CTW) the aws-lambda-powertools-java aspects into your project -->
32+
<build>
33+
<plugins>
34+
...
35+
<plugin>
36+
<groupId>dev.aspectj</groupId>
37+
<artifactId>aspectj-maven-plugin</artifactId>
38+
<version>1.13.1</version>
39+
<configuration>
40+
<source>11</source> <!-- or higher -->
41+
<target>11</target> <!-- or higher -->
42+
<complianceLevel>11</complianceLevel> <!-- or higher -->
43+
<aspectLibraries>
44+
<aspectLibrary>
45+
<groupId>software.amazon.lambda</groupId>
46+
<artifactId>powertools-logging</artifactId>
47+
</aspectLibrary>
48+
</aspectLibraries>
49+
</configuration>
50+
<executions>
51+
<execution>
52+
<goals>
53+
<goal>compile</goal>
54+
</goals>
55+
</execution>
56+
</executions>
57+
</plugin>
58+
...
59+
</plugins>
60+
</build>
61+
```
62+
63+
=== "Maven Java 1.8"
64+
65+
```xml hl_lines="3-7 16 18 24-27"
66+
<dependencies>
67+
...
68+
<dependency>
69+
<groupId>software.amazon.lambda</groupId>
70+
<artifactId>powertools-logging</artifactId>
71+
<version>{{ powertools.version }}</version>
72+
</dependency>
73+
...
74+
</dependencies>
75+
...
76+
<!-- configure the aspectj-maven-plugin to compile-time weave (CTW) the aws-lambda-powertools-java aspects into your project -->
77+
<build>
78+
<plugins>
79+
...
80+
<plugin>
81+
<groupId>org.codehaus.mojo</groupId>
82+
<artifactId>aspectj-maven-plugin</artifactId>
83+
<version>1.14.0</version>
84+
<configuration>
85+
<source>1.8</source>
86+
<target>1.8</target>
87+
<complianceLevel>1.8</complianceLevel>
88+
<aspectLibraries>
89+
<aspectLibrary>
90+
<groupId>software.amazon.lambda</groupId>
91+
<artifactId>powertools-logging</artifactId>
92+
</aspectLibrary>
93+
</aspectLibraries>
94+
</configuration>
95+
<executions>
96+
<execution>
97+
<goals>
98+
<goal>compile</goal>
99+
</goals>
100+
</execution>
101+
</executions>
102+
</plugin>
103+
...
104+
</plugins>
105+
</build>
106+
```
107+
108+
=== "Gradle Java 11+"
109+
110+
```groovy hl_lines="3 11"
111+
plugins {
112+
id 'java'
113+
id 'io.freefair.aspectj.post-compile-weaving' version '8.1.0'
114+
}
115+
116+
repositories {
117+
mavenCentral()
118+
}
119+
120+
dependencies {
121+
aspect 'software.amazon.lambda:powertools-logging:{{ powertools.version }}'
122+
}
123+
124+
sourceCompatibility = 11
125+
targetCompatibility = 11
126+
```
127+
128+
=== "Gradle Java 1.8"
129+
130+
```groovy hl_lines="3 11"
131+
plugins {
132+
id 'java'
133+
id 'io.freefair.aspectj.post-compile-weaving' version '6.6.3'
134+
}
135+
136+
repositories {
137+
mavenCentral()
138+
}
139+
140+
dependencies {
141+
aspect 'software.amazon.lambda:powertools-logging:{{ powertools.version }}'
142+
}
143+
144+
sourceCompatibility = 1.8
145+
targetCompatibility = 1.8
146+
```
147+
148+
14149
## Initialization
15150

16151
Powertools for AWS Lambda (Java) extends the functionality of Log4J. Below is an example `#!xml log4j2.xml` file, with the `JsonTemplateLayout` using `#!json LambdaJsonLayout.json` configured.

docs/core/metrics.md

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,139 @@ If you're new to Amazon CloudWatch, there are two terminologies you must be awar
2626
<figcaption>Metric terminology, visually explained</figcaption>
2727
</figure>
2828

29+
## Install
30+
31+
Depending on your version of Java (either Java 1.8 or 11+), the configuration slightly changes.
32+
33+
=== "Maven Java 11+"
34+
35+
```xml hl_lines="3-7 16 18 24-27"
36+
<dependencies>
37+
...
38+
<dependency>
39+
<groupId>software.amazon.lambda</groupId>
40+
<artifactId>powertools-metrics</artifactId>
41+
<version>{{ powertools.version }}</version>
42+
</dependency>
43+
...
44+
</dependencies>
45+
...
46+
<!-- configure the aspectj-maven-plugin to compile-time weave (CTW) the aws-lambda-powertools-java aspects into your project -->
47+
<build>
48+
<plugins>
49+
...
50+
<plugin>
51+
<groupId>dev.aspectj</groupId>
52+
<artifactId>aspectj-maven-plugin</artifactId>
53+
<version>1.13.1</version>
54+
<configuration>
55+
<source>11</source> <!-- or higher -->
56+
<target>11</target> <!-- or higher -->
57+
<complianceLevel>11</complianceLevel> <!-- or higher -->
58+
<aspectLibraries>
59+
<aspectLibrary>
60+
<groupId>software.amazon.lambda</groupId>
61+
<artifactId>powertools-metrics</artifactId>
62+
</aspectLibrary>
63+
</aspectLibraries>
64+
</configuration>
65+
<executions>
66+
<execution>
67+
<goals>
68+
<goal>compile</goal>
69+
</goals>
70+
</execution>
71+
</executions>
72+
</plugin>
73+
...
74+
</plugins>
75+
</build>
76+
```
77+
78+
=== "Maven Java 1.8"
79+
80+
```xml hl_lines="3-7 16 18 24-27"
81+
<dependencies>
82+
...
83+
<dependency>
84+
<groupId>software.amazon.lambda</groupId>
85+
<artifactId>powertools-metrics</artifactId>
86+
<version>{{ powertools.version }}</version>
87+
</dependency>
88+
...
89+
</dependencies>
90+
...
91+
<!-- configure the aspectj-maven-plugin to compile-time weave (CTW) the aws-lambda-powertools-java aspects into your project -->
92+
<build>
93+
<plugins>
94+
...
95+
<plugin>
96+
<groupId>org.codehaus.mojo</groupId>
97+
<artifactId>aspectj-maven-plugin</artifactId>
98+
<version>1.14.0</version>
99+
<configuration>
100+
<source>1.8</source>
101+
<target>1.8</target>
102+
<complianceLevel>1.8</complianceLevel>
103+
<aspectLibraries>
104+
<aspectLibrary>
105+
<groupId>software.amazon.lambda</groupId>
106+
<artifactId>powertools-metrics</artifactId>
107+
</aspectLibrary>
108+
</aspectLibraries>
109+
</configuration>
110+
<executions>
111+
<execution>
112+
<goals>
113+
<goal>compile</goal>
114+
</goals>
115+
</execution>
116+
</executions>
117+
</plugin>
118+
...
119+
</plugins>
120+
</build>
121+
```
122+
123+
=== "Gradle Java 11+"
124+
125+
```groovy hl_lines="3 11"
126+
plugins {
127+
id 'java'
128+
id 'io.freefair.aspectj.post-compile-weaving' version '8.1.0'
129+
}
130+
131+
repositories {
132+
mavenCentral()
133+
}
134+
135+
dependencies {
136+
aspect 'software.amazon.lambda:powertools-metrics:{{ powertools.version }}'
137+
}
138+
139+
sourceCompatibility = 11
140+
targetCompatibility = 11
141+
```
142+
143+
=== "Gradle Java 1.8"
144+
145+
```groovy hl_lines="3 11"
146+
plugins {
147+
id 'java'
148+
id 'io.freefair.aspectj.post-compile-weaving' version '6.6.3'
149+
}
150+
151+
repositories {
152+
mavenCentral()
153+
}
154+
155+
dependencies {
156+
aspect 'software.amazon.lambda:powertools-metrics:{{ powertools.version }}'
157+
}
158+
159+
sourceCompatibility = 1.8
160+
targetCompatibility = 1.8
161+
```
29162

30163
## Getting started
31164

0 commit comments

Comments
 (0)