Skip to content

Commit

Permalink
+ elf4j-engine version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
q3769 committed Oct 5, 2023
1 parent 33d9d9b commit 06db193
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 88 deletions.
72 changes: 29 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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
Expand All @@ -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"
}
```

Expand All @@ -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
```

Expand Down
10 changes: 2 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

<groupId>io.github.elf4j</groupId>
<artifactId>elf4j-provider</artifactId>
<version>11.0.2</version>
<version>12.0.0</version>
<packaging>jar</packaging>
<name>elf4j-provider</name>
<description>Native logging service provider implementation of ELF4J (Easy Logging Facade For Java)
Expand Down Expand Up @@ -68,13 +68,7 @@
<dependency>
<groupId>io.github.elf4j</groupId>
<artifactId>elf4j-engine</artifactId>
<version>12.0.5</version>
</dependency>
<dependency>
<groupId>io.github.q3769</groupId>
<artifactId>coco4j</artifactId>
<version>2.0.0</version>
<scope>test</scope>
<version>13.0.0</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
Expand Down
8 changes: 0 additions & 8 deletions src/test/java/elf4j/provider/IntegrationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 1 addition & 4 deletions src/test/java/elf4j/provider/Main.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
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 {
static Logger logger = Logger.instance();

public static void main(String[] args) throws InterruptedException {
public static void main(String[] args) {
logger.atInfo().log("Hello, world!");
Exception issue = new Exception("Test ex message");
logger.atWarn().log(issue, "Testing issue '{}' in {}", issue, Main.class);
Expand Down Expand Up @@ -51,7 +49,6 @@ public static void main(String[] args) throws InterruptedException {
"optional",
(Supplier) () -> "as usual");

MoreAwaitilities.sleepInterruptibly(Duration.ofMillis(200));
LogServiceManager.INSTANCE.shutdown();
}
}
8 changes: 0 additions & 8 deletions src/test/java/elf4j/provider/SampleUsageTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 3 additions & 17 deletions src/test/resources/elf4j-test.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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}

0 comments on commit 06db193

Please sign in to comment.