Skip to content

Commit cf68133

Browse files
authored
Show (#242)
* standardize CI workflow names to lowercase * removing threshold output level from LogWriter * Rename LogWriter classes and interfaces to LogEventWriter for clarity and consistency * documentation in log event writer classes and update version to 20.0.2
1 parent ad97326 commit cf68133

7 files changed

Lines changed: 29 additions & 35 deletions

File tree

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
<groupId>io.github.elf4j</groupId>
3333
<artifactId>elf4j-engine</artifactId>
34-
<version>20.0.1</version>
34+
<version>20.0.2</version>
3535
<packaging>jar</packaging>
3636
<name>elf4j-engine</name>
3737
<description>A stand-alone Java log engine implementing the ELF4J (Easy Logging Facade for Java) API</description>

src/main/java/elf4j/engine/logging/LogHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
public interface LogHandler {
3333
/**
3434
* @return true if the logger instance's severity level is at or above the configured minimum
35-
* threshold for the specified logger and writer, false otherwise
35+
* threshold for the specified logger, false otherwise
3636
*/
3737
boolean isEnabled(NativeLogger.LoggerId loggerId);
3838

src/main/java/elf4j/engine/logging/writer/CompositeLogEventWriter.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,12 @@
4444
import org.slf4j.MDC;
4545

4646
/**
47-
* In general, log events are asynchronously written/rendered in parallel by multiple concurrent
48-
* threads. However, events issued by the same caller application thread are rendered sequentially
49-
* with the {@link ConseqExecutor} API. Thus, logs by different caller threads may arrive at the
50-
* final destination (e.g. system Console or a log file) in any order; meanwhile, logs from the same
51-
* caller thread will arrive sequentially in the same order as they are called by such thread.
47+
* @implNote Log events are usually asynchronously written/rendered in parallel by multiple
48+
* concurrent threads. However, events issued by the same caller application thread are rendered
49+
* sequentially with the {@link ConseqExecutor} API. Thus, logs by different caller threads may
50+
* arrive at the final destination (e.g. system Console or a log file) in any order; meanwhile,
51+
* logs from the same caller thread will arrive sequentially in the same order as they are
52+
* called by such thread.
5253
*/
5354
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
5455
@ToString

src/main/java/elf4j/engine/logging/writer/LogEventWriter.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,18 @@
3434
* messages to an output destination e.g. the STDOUT stream, a log file, or a remote vendor log
3535
* collector (Datadog, Newrelic, ...). Implementations of this interface should be thread-safe.
3636
*
37+
* @apiNote A writer instance determines if the logging requires performance sensitive operations
38+
* (caller class/method/...). However, it does not concern itself with the logging threshold
39+
* levels.
40+
* @implSpec A {@link LogEventWriter} instance normally includes various log patterns. Collectively,
41+
* the patterns determine if the writer instance requires performance sensitive operations such
42+
* as the inclusion of caller detail.
3743
* @see PerformanceSensitive
3844
*/
3945
@ThreadSafe
4046
public interface LogEventWriter extends PerformanceSensitive {
4147
/**
42-
* Writes the given log event to the output destination(s) configured for this log writer.
48+
* Writes the given log event to the output destination(s) configured for this writer.
4349
*
4450
* @param logEvent the log data entry to write out
4551
*/

src/main/java/elf4j/engine/logging/writer/LogEventWriterFactory.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,8 @@
44

55
public interface LogEventWriterFactory {
66
/**
7-
* Returns a list of log writers of the enclosing writer type based on the provided logging
8-
* configuration.
9-
*
107
* @param configurationProperties the entire log service configuration
11-
* @return all log writers of the enclosing writer type from the given configuration
8+
* @return a log event writer instance based on the provided configuration
129
*/
1310
LogEventWriter getWriter(Properties configurationProperties);
1411
}

src/main/java/elf4j/engine/logging/writer/StandardStreamLogEventWriter.java

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727

2828
import static elf4j.engine.logging.writer.StandardStreamLogEventWriter.OutStreamType.STDOUT;
2929

30-
import elf4j.Level;
3130
import elf4j.Logger;
3231
import elf4j.engine.logging.LogEvent;
3332
import elf4j.engine.logging.pattern.RenderingPattern;
@@ -39,20 +38,16 @@
3938
import lombok.Value;
4039

4140
/**
42-
* A log writer implementation that writes log events to the standard output or standard error
43-
* stream. The log pattern, threshold output level, and target stream (stdout or stderr) can be
44-
* configured.
41+
* A log event writer targeting the standard stream output destination. The log pattern and target
42+
* stream type (stdout or stderr) can be configured.
43+
*
44+
* @apiNote Due to the implementation approach on output synchrony and atomicity, this writer - and
45+
* the elf4j-engine in general - is not intended to be used simultaneously with other logging
46+
* providers. Otherwise, logs from different providers may intertwine.
4547
*/
4648
@Value
4749
@ToString
4850
public class StandardStreamLogEventWriter implements LogEventWriter {
49-
/**
50-
* For simplicity, the standard stream writer threshold level is always set to TRACE and not
51-
* configurable, regardless of whether the output stream is stdout or stderr. i.e. it is entirely
52-
* up to the logger name threshold level whether a specific log is printed or not.
53-
*/
54-
static final Level DEFAULT_WRITER_THRESHOLD_LEVEL = Level.TRACE;
55-
5651
static final String DEFAULT_PATTERN = "{timestamp} {level} {logger} - {message}";
5752
static final OutStreamType DEFAULT_OUT_STREAM_TYPE = STDOUT;
5853
static final String LINE_FEED = System.lineSeparator();
@@ -115,10 +110,10 @@ private static final class StandardOutputStream {
115110

116111
/**
117112
* Locking is in the default "unfair" mode for performance. This means under contention, logs
118-
* from different threads may appear in the final destination in any order. However, 1) the
119-
* (unchanged) timestamps on the logs still reflect the chronicle order, and can/should be used
120-
* to sort the logs when viewing them; and 2) the logs from the same thread are still ensured to
121-
* appear in the same order as the thread requested.
113+
* from different caller threads may appear in the final destination in any order. However, 1)
114+
* the (unchanged) timestamps on the logs still reflect the chronicle order, and can/should be
115+
* used to sort the logs when viewing them; and 2) the logs from the same caller thread are
116+
* still ensured to appear in the same order as the thread requested.
122117
*/
123118
private static final Lock OUTPUT_LOCK = new java.util.concurrent.locks.ReentrantLock(false);
124119

@@ -136,9 +131,8 @@ public StandardOutputStream(OutStreamType outStreamType) {
136131
}
137132

138133
/**
139-
* This method is supposed to be called once and only once per each entirely complete log
140-
* message.
141-
*
134+
* @apiNote This method is supposed to be called once and only once per each entirely complete
135+
* log message.
142136
* @param bytes of the completely rendered log message to write to the target output stream
143137
*/
144138
public void write(byte[] bytes) {

src/test/java/elf4j/engine/SampleUsageTest.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727

2828
import static org.junit.jupiter.api.Assertions.assertTrue;
2929

30-
import elf4j.Level;
3130
import elf4j.Logger;
3231
import java.util.function.Supplier;
3332
import org.junit.jupiter.api.Nested;
@@ -74,10 +73,7 @@ void convenienceShorthands() {
7473
debugLogger.isDebugEnabled(),
7574
"Assuming minimum threshold level configured is TRACE, thus DEBUG severity log level should be enabled");
7675
if (debugLogger.isDebugEnabled()) {
77-
debugLogger.debug(
78-
"The DEBUG severity level log message '{}' will print here as the default minimum writer threshold level is {}",
79-
message,
80-
Level.TRACE);
76+
debugLogger.debug("The DEBUG severity level log message '{}' will print here", message);
8177
}
8278
}
8379
}

0 commit comments

Comments
 (0)