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 Mar 25, 2023
1 parent 00067f6 commit 290626f
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 27 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Java 8 or better

* Configuration Refresh at Runtime

Supports configuration refresh during runtime via API, with option of passing in overriding properties in addition to
Supports configuration refresh during runtime via API, with option of passing in replacement properties instead of
reloading the configuration file. The most frequent use case would be to change the minimum log output level, without
restarting the application.

Expand Down Expand Up @@ -104,7 +104,8 @@ configuration sample file below.

**Level**

The default global logger minimum output level is `TRACE`. Supports global and package level customizations.
The default level of a logger from the static factory method `Logger.instance()` is `INFO`. The default global minimum
logging output level is `TRACE`; elf4j-engine supports global and package level customizations.

**Writer**

Expand All @@ -124,7 +125,8 @@ writer patterns and various minimum output levels per caller classes, more than
* file name: No configuration options, simple file name
* line number: No configuration options, where the log is issued in the file
* log message: No configuration options, always prints user message, and exception stack trace if any
* json: Options to include thread (name, id) and caller (method, line number, file name) details and pretty-print the JSON
* json: Options to include thread (name, id) and caller (method, line number, file name) details and pretty-print the
JSON
string, default is no thread/caller detail and the minified single-line format

**Output samples**
Expand Down Expand Up @@ -222,4 +224,4 @@ writer2.pattern={json:caller-thread,caller-detail,pretty}

`ServiceConfigurationManager.refreshConfiguration()` will reload the configuration file and apply the latest file
properties during runtime. `ServiceConfigurationManager.refreshConfiguration(Properties)` will apply the passed-in
properties as override, in addition to reloading the configuration file.
properties as replacement, instead of reloading the configuration file.
25 changes: 3 additions & 22 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>2.1.1</version>
<version>3.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,7 +68,7 @@
<dependency>
<groupId>io.github.elf4j</groupId>
<artifactId>elf4j-engine</artifactId>
<version>1.1.3</version>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
Expand All @@ -94,12 +94,6 @@
<version>5.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.26</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -134,20 +128,7 @@
<plugin>
<groupId>io.github.q3769</groupId>
<artifactId>semver-maven-plugin</artifactId>
<version>20221011.0.8</version>
</plugin>
<plugin>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-maven-plugin</artifactId>
<version>1.18.20.0</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>delombok</goal>
</goals>
</execution>
</executions>
<version>20221011.0.9</version>
</plugin>
</plugins>
</build>
Expand Down
54 changes: 54 additions & 0 deletions src/test/java/elf4j/provider/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package elf4j.provider;

import elf4j.Logger;
import elf4j.engine.service.LogServiceManager;

import java.util.function.Supplier;

public class Main {
static Logger logger = Logger.instance();

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);

logger.log(
"Logger instance is thread-safe so it can be declared and used as a local, instance, or static variable");
logger.log("Default severity level is decided by the logging provider implementation");
Logger trace = logger.atTrace();
trace.log("Explicit severity level is specified by user i.e. TRACE");
Logger.instance().atTrace().log("Same explicit level TRACE");
logger.atDebug().log("Severity level is DEBUG");
logger.atInfo().log("Severity level is INFO");
trace.atWarn().log("Severity level is WARN, not TRACE");
logger.atError().log("Severity level is ERROR");
Logger.instance()
.atDebug()
.atError()
.atTrace()
.atWarn()
.atInfo()
.log("Not a practical example but the severity level is INFO");

Logger info = logger.atInfo();
info.log("Message can have any number of arguments of {} type", Object.class.getTypeName());
info.log(
"Lazy arguments, of {} type, whose values may be {} can be mixed with eager arguments of non-Supplier types",
Supplier.class.getTypeName(),
(Supplier) () -> "expensive to compute");
info.atWarn()
.log("The Supplier downcast is mandatory per lambda syntax because arguments are declared as generic Object rather than functional interface");

Exception exception = new Exception("Exception message");
logger.atError().log(exception);
logger.atError().log(exception, "Optional log message");
logger.atInfo()
.log(exception,
"Exception is always the first argument to a logging method. The {} log message and following arguments work the same way {}.",
"optional",
(Supplier) () -> "as usual");

LogServiceManager.shutdown();
}
}
2 changes: 1 addition & 1 deletion src/test/resources/elf4j-test.properties
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#noop=true
### Any level is optional, default to TRACE if omitted
### This override the default global level
level=info
#level=info
standard.stream=stderr
### These override level of all caller classes included the specified package
level@org.springframework=warn
Expand Down

0 comments on commit 290626f

Please sign in to comment.