Skip to content
This repository was archived by the owner on Jun 4, 2024. It is now read-only.

Commit a170bf8

Browse files
committed
Merge branch 'site' into 'main'
Update site Closes #21 See merge request bot-by/slf4j-aws-lambda!18
2 parents e2b3725 + 81f9f1d commit a170bf8

File tree

23 files changed

+284
-116
lines changed

23 files changed

+284
-116
lines changed

.gitlab-ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ stages:
2222
build:
2323
stage: build
2424
script:
25-
- mvn $MAVEN_CLI_OPTS compile
25+
- mvn $MAVEN_CLI_OPTS clean compile
2626
except:
2727
- tags
2828

@@ -60,15 +60,15 @@ sast:
6060
release:
6161
stage: deploy
6262
script:
63-
- mvn $MAVEN_CLI_OPTS -s ci_settings.xml -pl core,logger,json-logger,. -am deploy -ntp -Psources,javadocs,sign-and-deploy
63+
- mvn $MAVEN_CLI_OPTS -s ci_settings.xml -pl core,logger,json-logger,. -am deploy -ntp -Dchangelist= -Psources,javadocs,sign-and-deploy
6464
only:
6565
- tags
6666

6767
pages:
6868
stage: deploy
6969
script:
7070
- cp changelog.md src/site/markdown
71-
- mvn $MAVEN_CLI_OPTS -pl . verify site site:stage -Pjavadocs,site
71+
- mvn $MAVEN_CLI_OPTS -pl . verify site site:stage -Dchangelist= -Pjavadocs,site
7272
artifacts:
7373
paths:
7474
- public

core/pom.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@
114114
<parent>
115115
<artifactId>slf4j-aws-lambda-parent</artifactId>
116116
<groupId>uk.bot-by</groupId>
117-
<version>1.0.0-SNAPSHOT</version>
117+
<version>${revision}${changelist}${sha1}</version>
118118
</parent>
119-
<version>1.0.0-SNAPSHOT</version>
120119
</project>

core/src/main/java/uk/bot_by/aws_lambda/slf4j/AWSLambdaLogger.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,15 +373,15 @@ void log(Level level, String message, Throwable throwable) {
373373
if (!isLevelEnabled(level)) {
374374
return;
375375
}
376-
output.log(configuration, level, message, throwable);
376+
output.log(configuration, null, level, message, throwable);
377377
}
378378

379379
@VisibleForTesting
380380
void log(Level level, Marker marker, String message, Throwable throwable) {
381381
if (!isLevelEnabled(level, marker)) {
382382
return;
383383
}
384-
output.log(configuration, level, message, throwable);
384+
output.log(configuration, marker, level, message, throwable);
385385
}
386386

387387
private void formatAndLog(Level level, String format, Object... arguments) {

core/src/main/java/uk/bot_by/aws_lambda/slf4j/AWSLambdaLoggerOutput.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import org.jetbrains.annotations.NotNull;
1919
import org.jetbrains.annotations.Nullable;
20+
import org.slf4j.Marker;
2021
import org.slf4j.event.Level;
2122

2223
/**
@@ -28,11 +29,12 @@ public interface AWSLambdaLoggerOutput {
2829
* Write a message to the log.
2930
*
3031
* @param configuration logging configuration
31-
* @param level logger level
32+
* @param marker logging marker
33+
* @param level logging level
3234
* @param message logging message
3335
* @param throwable exception
3436
*/
35-
void log(@NotNull AWSLambdaLoggerConfiguration configuration, @NotNull Level level,
36-
@NotNull String message, @Nullable Throwable throwable);
37+
void log(@NotNull AWSLambdaLoggerConfiguration configuration, @Nullable Marker marker,
38+
@NotNull Level level, @NotNull String message, @Nullable Throwable throwable);
3739

3840
}

core/src/test/java/org/example/TestServiceProvider.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import org.jetbrains.annotations.NotNull;
44
import org.jetbrains.annotations.Nullable;
5+
import org.slf4j.Marker;
56
import org.slf4j.event.Level;
67
import uk.bot_by.aws_lambda.slf4j.AWSLambdaLoggerConfiguration;
78

@@ -13,8 +14,8 @@ public String hello() {
1314
}
1415

1516
@Override
16-
public void log(@NotNull AWSLambdaLoggerConfiguration configuration, @NotNull Level level,
17-
@NotNull String message, @Nullable Throwable throwable) {
17+
public void log(@NotNull AWSLambdaLoggerConfiguration configuration, @Nullable Marker marker,
18+
@NotNull Level level, @NotNull String message, @Nullable Throwable throwable) {
1819
hello();
1920
}
2021

core/src/test/java/uk/bot_by/aws_lambda/slf4j/EnvironmentVariablesTest.java

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import static org.junit.jupiter.api.Assertions.assertAll;
55
import static org.junit.jupiter.api.Assertions.assertEquals;
66
import static org.junit.jupiter.api.Assertions.assertFalse;
7+
import static org.junit.jupiter.api.Assertions.assertNotNull;
78
import static org.junit.jupiter.api.Assertions.assertNull;
89
import static org.junit.jupiter.api.Assertions.assertTrue;
910
import static org.mockito.ArgumentMatchers.any;
@@ -45,6 +46,8 @@ class EnvironmentVariablesTest {
4546
private ArgumentCaptor<AWSLambdaLoggerConfiguration> configurationCaptor;
4647
@Captor
4748
private ArgumentCaptor<Level> levelCaptor;
49+
@Captor
50+
private ArgumentCaptor<Marker> markerCaptor;
4851
@Mock
4952
private AWSLambdaLoggerOutput output;
5053
@Captor
@@ -84,8 +87,8 @@ void useEnvironmentVariables() {
8487
logger.trace("trace message");
8588

8689
// then
87-
verify(output).log(configurationCaptor.capture(), levelCaptor.capture(), stringCaptor.capture(),
88-
isNull());
90+
verify(output).log(configurationCaptor.capture(), isNull(), levelCaptor.capture(),
91+
stringCaptor.capture(), isNull());
8992

9093
var configuration = configurationCaptor.getValue();
9194

@@ -112,12 +115,14 @@ void defaultLogLevelWithMarker() {
112115
logger.trace(marker, "trace message");
113116

114117
// then
115-
verify(output).log(configurationCaptor.capture(), levelCaptor.capture(), stringCaptor.capture(),
116-
isNull());
118+
verify(output).log(configurationCaptor.capture(), markerCaptor.capture(), levelCaptor.capture(),
119+
stringCaptor.capture(), isNull());
117120

118121
var configuration = configurationCaptor.getValue();
119122

120123
assertAll("Default level with a marker",
124+
() -> assertNotNull(markerCaptor.getValue(), "marker not null"),
125+
() -> assertEquals("aMarker", markerCaptor.getValue().getName(), "marker"),
121126
() -> assertFalse(configuration.isLevelEnabled(Level.TRACE), "level without a marker"),
122127
() -> assertTrue(configuration.isLevelEnabled(Level.TRACE, marker), "level with a marker"),
123128
() -> assertEquals(Level.TRACE, levelCaptor.getValue(), "level"),
@@ -151,7 +156,7 @@ void implementNoneLevel(String markerName) {
151156
}
152157

153158
// then
154-
verify(output, never()).log(any(), any(), anyString(), any());
159+
verify(output, never()).log(any(), any(), any(), anyString(), any());
155160
}
156161

157162
@DisplayName("Wrong a date-time format")
@@ -171,8 +176,8 @@ void wrongDateTimeFormat() {
171176
logger.warn("warn message");
172177

173178
// then
174-
verify(output).log(configurationCaptor.capture(), levelCaptor.capture(), stringCaptor.capture(),
175-
isNull());
179+
verify(output).log(configurationCaptor.capture(), isNull(), levelCaptor.capture(),
180+
stringCaptor.capture(), isNull());
176181

177182
var configuration = configurationCaptor.getValue();
178183

@@ -199,8 +204,8 @@ void wrongDefaultLoggerLever() {
199204
logger.debug("debug message");
200205

201206
// then
202-
verify(output).log(configurationCaptor.capture(), levelCaptor.capture(), stringCaptor.capture(),
203-
isNull());
207+
verify(output).log(configurationCaptor.capture(), isNull(), levelCaptor.capture(),
208+
stringCaptor.capture(), isNull());
204209

205210
var configuration = configurationCaptor.getValue();
206211

core/src/test/java/uk/bot_by/aws_lambda/slf4j/PropertiesTest.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,8 @@ void useLoggerProperties() {
300300
loggerFactory.getLogger("lambda.logger.test").debug("debug message");
301301

302302
// then
303-
verify(output).log(configurationCaptor.capture(), levelCaptor.capture(), stringCaptor.capture(),
304-
isNull());
303+
verify(output).log(configurationCaptor.capture(), isNull(), levelCaptor.capture(),
304+
stringCaptor.capture(), isNull());
305305

306306
var configuration = configurationCaptor.getValue();
307307

@@ -332,8 +332,8 @@ void missedProperties() {
332332
logger.info("info message");
333333

334334
// then
335-
verify(output).log(configurationCaptor.capture(), levelCaptor.capture(), stringCaptor.capture(),
336-
isNull());
335+
verify(output).log(configurationCaptor.capture(), isNull(), levelCaptor.capture(),
336+
stringCaptor.capture(), isNull());
337337

338338
var configuration = configurationCaptor.getValue();
339339

@@ -363,8 +363,8 @@ void wrongDateTimeFormat() {
363363
loggerFactory.getLogger("lambda.logger.test").info("info message");
364364

365365
// then
366-
verify(output).log(configurationCaptor.capture(), levelCaptor.capture(), stringCaptor.capture(),
367-
isNull());
366+
verify(output).log(configurationCaptor.capture(), isNull(), levelCaptor.capture(),
367+
stringCaptor.capture(), isNull());
368368

369369
var configuration = configurationCaptor.getValue();
370370

@@ -395,8 +395,8 @@ void wrongDefaultLoggerLevel() {
395395
logger.info("info message");
396396

397397
// then
398-
verify(output).log(configurationCaptor.capture(), levelCaptor.capture(), stringCaptor.capture(),
399-
isNull());
398+
verify(output).log(configurationCaptor.capture(), isNull(), levelCaptor.capture(),
399+
stringCaptor.capture(), isNull());
400400

401401
var configuration = configurationCaptor.getValue();
402402

@@ -428,8 +428,8 @@ void wrongLoggerLevel() {
428428
logger.debug("debug message");
429429

430430
// then
431-
verify(output).log(configurationCaptor.capture(), levelCaptor.capture(), stringCaptor.capture(),
432-
isNull());
431+
verify(output).log(configurationCaptor.capture(), isNull(), levelCaptor.capture(),
432+
stringCaptor.capture(), isNull());
433433

434434
var configuration = configurationCaptor.getValue();
435435

File renamed without changes.

example-lambda-json/pom.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
<dependency>
7878
<artifactId>slf4j-aws-lambda-json-logger</artifactId>
7979
<groupId>uk.bot-by</groupId>
80-
<version>1.0.0-SNAPSHOT</version>
80+
<version>${revision}${changelist}${sha1}</version>
8181
<scope>runtime</scope>
8282
</dependency>
8383
</dependencies>
@@ -87,11 +87,10 @@
8787
<parent>
8888
<artifactId>slf4j-aws-lambda-parent</artifactId>
8989
<groupId>uk.bot-by</groupId>
90-
<version>1.0.0-SNAPSHOT</version>
90+
<version>${revision}${changelist}${sha1}</version>
9191
</parent>
9292
<properties>
9393
<aws-request-id>request#</aws-request-id>
9494
<lambda.name>example-lambda</lambda.name>
9595
</properties>
96-
<version>1.0.0-SNAPSHOT</version>
9796
</project>

example-lambda-json/readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,6 @@ The expected log lines
5454
```
5555

5656
The screenshot of CloudWatch log
57-
![Maven Central](cloudwatch-screenshot.png)
57+
![Maven Central](cloudwatch-json-screenshot.png)
5858

5959
[deploy-lambda]: https://github.com/davidmoten/aws-maven-plugin#deploy-to-lambda

0 commit comments

Comments
 (0)