From 0cc8f150d61003de1e9c15cf87ae62d13152e3f1 Mon Sep 17 00:00:00 2001 From: q3769 Date: Wed, 4 Oct 2023 21:55:47 -0500 Subject: [PATCH] + elf4j-engine version bump --- README.md | 72 ++++++++----------- pom.xml | 10 +-- .../java/elf4j/provider/IntegrationTest.java | 8 --- src/test/java/elf4j/provider/Main.java | 3 - .../java/elf4j/provider/SampleUsageTest.java | 8 --- src/test/resources/elf4j-test.properties | 20 +----- 6 files changed, 34 insertions(+), 87 deletions(-) diff --git a/README.md b/README.md index d863082..a887242 100644 --- a/README.md +++ b/README.md @@ -114,23 +114,24 @@ both the log caller class and the log writer. * The default severity level of a `Logger` instance from `Logger.instance()` is `INFO`, which is not configurable: The elf4j [API](https://github.com/elf4j/elf4j#logging-service-interface-and-access-api) should be used to programmatically obtain `Logger` instances of desired severity levels. -* The default minimum output level for both log caller classes and writers and is `TRACE`, which is configurable: For - caller classes, the minimum output level can be configured on global, package, or individual class levels. For - writers, the level can be configured on global level and overridden per each writer. +* The default minimum output level for both log caller classes and the writer and is `TRACE`, which is configurable: For + caller classes, the minimum output level can be configured on global, package, or individual class levels. ### Writer -The elf4j-engine supports multiple standard-stream writers. Each writer can have individual configurations on format -pattern and minimum output level. The same log entry will be output once per each writer. Practically, however, more -than one writer is rarely necessary given what a single writer can achieve with the comprehensive support on log -patterns and minimum output levels per caller classes. +By default, the elf4j-engine supports one single writer instance of the standard-stream type. The codebase is +extension-ready for multiple, different writer types; and for each custom type, multiple writer instances. However, the +need for such extensions (e.g. flat-file writers) is rare, considering the abundant host/OS and vendor level support +options to ship standard-stream application log data to various destinations other than the default system console. ### Output format pattern All individual patterns, including the JSON pattern, can either be the only output of the log entry, or mixed together -with any other patterns. They take the form of `{pattern:displayOptions}`, where multiple display options are separated -by commas. Patterns inside curly brace pairs are predefined and will be interpreted before output, while patterns -outside curly brace pairs are output verbatim. The predefined patterns are: +with any other patterns. They each take the form of `{pattern:displayOptions}`, where multiple display options are +separated by commas. Patterns inside curly brace pairs are predefined and will be interpreted before output, while +patterns outside curly brace pairs are written out verbatim. + +The predefined patterns are: * `timestamp`: Date time format configurable via Java `DateTimeFormatter` [pattern syntax](https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html#patterns), @@ -187,7 +188,7 @@ JSON Default ``` * Output: ``` - {"timestamp":"2023-03-22T21:21:29.7319284-05:00","level":"INFO","callerClass":"elf4j.engine.IntegrationTest$defaultLogger","message":"Hello, world!"} + {"message":"Hello, world!","timestamp":"2023-10-04T09:11:10.8063059-05:00","level":"INFO","callerClass":"elf4j.provider.Main"} ``` JSON Customized @@ -199,19 +200,20 @@ JSON Customized * Output: ```json { - "timestamp": "2023-03-14T21:21:33.1180212-05:00", - "level": "INFO", - "callerThread": { - "name": "main", - "id": 1 - }, - "callerDetail": { - "className": "elf4j.provider.IntegrationTest$defaultLogger", - "methodName": "hey", - "lineNumber": 41, - "fileName": "IntegrationTest.java" - }, - "message": "Hello, world!" + "message": "Exception is always the first argument to a logging method. The optional log message and following arguments work the same way as usual.", + "timestamp": "2023-10-04T09:09:46.2091508-05:00", + "level": "INFO", + "callerThread": { + "name": "main", + "id": 1 + }, + "callerDetail": { + "className": "elf4j.provider.Main", + "methodName": "main", + "lineNumber": 49, + "fileName": "Main.java" + }, + "exception": "java.lang.Exception: Exception message\r\n\tat elf4j.provider.Main.main(Main.java:45)\r\n" } ``` @@ -221,30 +223,14 @@ JSON Customized ### Zero configuration mandatory, this file can be empty - default to a line-based writer with simple log pattern ### global no-op flag, overriding and will turn off all logging if set true #noop=true -### Minimum output level is optional, default to TRACE for all caller classes if omitted +### Minimum writer output level is optional, default to TRACE for all caller classes if omitted level=info -### These override the output level of all caller classes included the specified package spaces +### These override the writer output level of all caller classes included the specified package spaces level@org.springframework=warn level@org.apache=error ### Standard out stream type, stdout or stderr, default is stdout stream=stderr -### Global writer output pattern if omitted on individual writer, default to a simple line based -#pattern={json} -### Any writer is optional, default to a simple standard streams writer -### 'standard' is currently the only supported writer type -writer1=standard -### This is the default output pattern, can be omitted -#writer1.pattern={timestamp} {level} {class} - {message} -### This would customize the format patterns of the specified writer -#writer1.pattern={timestamp:yyyy-MM-dd'T'HH:mm:ss.SSSXXX} {level:5} [{thread:id}] {class:compressed}#{method}(L{linenumber}@{filename}) - {message} -### Multiple writers are supported, each with its own configurations -writer2=standard -#writer2.level=trace -### Default json pattern does not include thread and caller details, and uses minified one-line format for the JSON string -#writer2.pattern={json} -### This would force the JSON to include the thread/caller details, and pretty print -writer2.pattern={json:caller-thread,caller-detail,pretty} -### Optional log event processing concurrency, default is jvm runtime available processors at application start time +### Max concurrency to process logs from different caller threads, default to available runtime processors #concurrency=20 ``` diff --git a/pom.xml b/pom.xml index 9494f55..3558714 100644 --- a/pom.xml +++ b/pom.xml @@ -31,7 +31,7 @@ io.github.elf4j elf4j-provider - 11.0.2 + 12.0.0 jar elf4j-provider Native logging service provider implementation of ELF4J (Easy Logging Facade For Java) @@ -68,13 +68,7 @@ io.github.elf4j elf4j-engine - 12.0.5 - - - io.github.q3769 - coco4j - 2.0.0 - test + 13.0.0 org.junit.jupiter diff --git a/src/test/java/elf4j/provider/IntegrationTest.java b/src/test/java/elf4j/provider/IntegrationTest.java index b7f2243..92cee01 100644 --- a/src/test/java/elf4j/provider/IntegrationTest.java +++ b/src/test/java/elf4j/provider/IntegrationTest.java @@ -25,22 +25,14 @@ package elf4j.provider; -import coco4j.MoreAwaitilities; import elf4j.Logger; import elf4j.engine.NativeLogger; -import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; -import java.time.Duration; - import static org.junit.jupiter.api.Assertions.assertEquals; class IntegrationTest { - @AfterEach - void afterEach() { - MoreAwaitilities.sleepInterruptibly(Duration.ofMillis(500)); - } @Nested class defaultLogger { diff --git a/src/test/java/elf4j/provider/Main.java b/src/test/java/elf4j/provider/Main.java index ccaa288..57c4627 100644 --- a/src/test/java/elf4j/provider/Main.java +++ b/src/test/java/elf4j/provider/Main.java @@ -1,10 +1,8 @@ package elf4j.provider; -import coco4j.MoreAwaitilities; import elf4j.Logger; import elf4j.engine.service.LogServiceManager; -import java.time.Duration; import java.util.function.Supplier; public class Main { @@ -51,7 +49,6 @@ public static void main(String[] args) throws InterruptedException { "optional", (Supplier) () -> "as usual"); - MoreAwaitilities.sleepInterruptibly(Duration.ofMillis(200)); LogServiceManager.INSTANCE.shutdown(); } } diff --git a/src/test/java/elf4j/provider/SampleUsageTest.java b/src/test/java/elf4j/provider/SampleUsageTest.java index 9670df7..123ab25 100644 --- a/src/test/java/elf4j/provider/SampleUsageTest.java +++ b/src/test/java/elf4j/provider/SampleUsageTest.java @@ -25,23 +25,15 @@ package elf4j.provider; -import coco4j.MoreAwaitilities; import elf4j.Logger; -import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; -import java.time.Duration; import java.util.function.Supplier; class SampleUsageTest { static Logger logger = Logger.instance(); - @AfterEach - void afterEach() { - MoreAwaitilities.sleepInterruptibly(Duration.ofMillis(500)); - } - @Nested class plainText { @Test diff --git a/src/test/resources/elf4j-test.properties b/src/test/resources/elf4j-test.properties index d6424b4..f08b056 100644 --- a/src/test/resources/elf4j-test.properties +++ b/src/test/resources/elf4j-test.properties @@ -33,20 +33,6 @@ stream=stderr ### These override level of all caller classes included the specified package level@org.springframework=warn ### Any writer is optional, default to a single standard writer if no writer configured -writer1=standard -### This is the default output pattern, can be omitted -#writer1.pattern={timestamp} {level} [{thread}] {class} - {message} -### This will customize the format patterns of the specified writer -#writer1.pattern={timestamp:yyyy-MM-dd'T'HH:mm:ss.SSSXXX} {level:5} [{thread:id}] {class:compressed}#{method}(L{linenumber}@{filename}) - {message} -### Multiple writers are supported, each with its own configurations -writer2=standard -#writer2.level=trace -### Default json pattern does not include thread and caller details, and uses minified one-line format for the JSON string -#writer2.pattern={json} -### This would force the JSON to include the thread/caller details -writer2.pattern={json:caller-thread,caller-detail,pretty} -### This would print JSON string in pretty format -#writer2.pattern={json:caller-thread,caller-detail,pretty} -### This would force the writer to use stderr instead of stdout -writer3=standard -writer3.pattern={json:pretty} +pattern={json} +#pattern={json:caller-thread,caller-detail,pretty} +#pattern={timestamp:yyyy-MM-dd'T'HH:mm:ss.SSSXXX} {level:5} [{thread:id}] {class:compressed}#{method}(L{linenumber}@{filename}) - {message}