Skip to content

Commit

Permalink
dev
Browse files Browse the repository at this point in the history
  • Loading branch information
q3769 committed Mar 21, 2023
1 parent 80473e7 commit 453dc0b
Show file tree
Hide file tree
Showing 14 changed files with 25 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import elf4j.impl.core.writer.StandardStreamsWriter;
import lombok.NonNull;

import javax.annotation.Nonnull;
import java.util.Properties;

/**
Expand All @@ -48,7 +49,7 @@ private WriterRepository(LogWriter logServiceWriter) {
/**
* @param properties configuration from which to build the writer repo
*/
static WriterRepository from(@NonNull Properties properties) {
static @Nonnull WriterRepository from(@NonNull Properties properties) {
GroupWriter groupWriter = GroupWriter.from(properties);
if (!groupWriter.isEmpty()) {
InternalLogger.log(Level.INFO,
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/elf4j/impl/core/service/LogEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class LogEntry {
@Nullable StackTraceFrame callerFrame;
@Nullable ThreadInformation callerThread;

private static String resolve(Object msg, Object[] arguments) {
private static @NonNull String resolve(Object msg, Object[] arguments) {
String message = Objects.toString(supply(msg), "");
int messageLength = message.length();
StringBuilder builder = new StringBuilder(messageLength + ADDITIONAL_STRING_BUILDER_CAPACITY);
Expand Down Expand Up @@ -98,7 +98,7 @@ public static class StackTraceFrame {
@NonNull String className;
@NonNull String methodName;
int lineNumber;
@NonNull String fileName;
String fileName;
}

/**
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/elf4j/impl/core/util/PropertiesUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

package elf4j.impl.core.util;

import lombok.NonNull;

import java.util.Map;
import java.util.Properties;
import java.util.Set;
Expand All @@ -44,7 +46,7 @@ private PropertiesUtils() {
* @return all properties entries whose original keys start with the specified prefix. The prefix is removed from
* the keys of the returned entries.
*/
public static Map<String, String> getChildProperties(String prefix, Properties properties) {
public static Map<String, String> getChildProperties(String prefix, @NonNull Properties properties) {
final String start = prefix + '.';
return properties.stringPropertyNames()
.stream()
Expand All @@ -59,7 +61,7 @@ public static Map<String, String> getChildProperties(String prefix, Properties p
* @return a group whose every member is a set of properties entries having a common key prefix of the specified
* type
*/
public static Set<Map<String, String>> getPropertiesGroupOfType(String type, Properties properties) {
public static Set<Map<String, String>> getPropertiesGroupOfType(String type, @NonNull Properties properties) {
return properties.stringPropertyNames()
.stream()
.filter(name -> properties.getProperty(name).trim().equals(type))
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/elf4j/impl/core/util/StackTraceUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public static LogEntry.StackTraceFrame callerOf(@NonNull Class<?> calleeClass) {
* @param throwable to extract stack trace text from
* @return stack trace text of the specified throwable
*/
public static String stackTraceTextOf(Throwable throwable) {
public static String stackTraceTextOf(@NonNull Throwable throwable) {
try (StringWriter stringWriter = new StringWriter(); PrintWriter printWriter = new PrintWriter(stringWriter)) {
throwable.printStackTrace(printWriter);
return stringWriter.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
import elf4j.impl.core.service.LogEntry;
import elf4j.impl.core.writer.pattern.LogPattern;
import elf4j.impl.core.writer.pattern.PatternSegmentGroup;
import lombok.NonNull;

import javax.annotation.Nonnull;
import java.io.BufferedOutputStream;
import java.io.PrintStream;
import java.util.Map;
Expand All @@ -55,7 +57,7 @@ private StandardStreamsWriter(Level minimumLevel, PatternSegmentGroup logPattern
/**
* @return default writer
*/
public static StandardStreamsWriter defaultWriter() {
public static @Nonnull StandardStreamsWriter defaultWriter() {
return new StandardStreamsWriter(DEFAULT_MINIMUM_LEVEL,
PatternSegmentGroup.from(DEFAULT_PATTERN),
DEFAULT_OUT_STREAM);
Expand All @@ -65,7 +67,7 @@ public static StandardStreamsWriter defaultWriter() {
* @param configuration properties map to make a console writer
* @return console writer per the specified configuration
*/
public static StandardStreamsWriter from(Map<String, String> configuration) {
public static @NonNull StandardStreamsWriter from(@NonNull Map<String, String> configuration) {
String level = configuration.get("level");
String pattern = configuration.get("pattern");
String outStreamType = configuration.get("stream");
Expand All @@ -80,7 +82,7 @@ public Level getMinimumLevel() {
}

@Override
public void write(LogEntry logEntry) {
public void write(@NonNull LogEntry logEntry) {
if (this.minimumLevel.ordinal() > logEntry.getNativeLogger().getLevel().ordinal()) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public boolean includeCallerThread() {
}

@Override
public void render(LogEntry logEntry, StringBuilder logTextBuilder) {
public void render(@NonNull LogEntry logEntry, StringBuilder logTextBuilder) {
String fullName = logEntry.getCallerClassName();
switch (classDisplayOption) {
case FULL:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ static class JsonLogEntry {
String message;
String exception;

static JsonLogEntry from(LogEntry logEntry, JsonPatternSegment jsonPatternSegment) {
static JsonLogEntry from(@NonNull LogEntry logEntry, @NonNull JsonPatternSegment jsonPatternSegment) {
return JsonLogEntry.builder()
.timestamp(DATE_TIME_FORMATTER.format(logEntry.getTimestamp()))
.callerClass(jsonPatternSegment.includeCallerDetail ? null : logEntry.getCallerClassName())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public boolean includeCallerThread() {
}

@Override
public void render(LogEntry logEntry, StringBuilder logTextBuilder) {
public void render(@NonNull LogEntry logEntry, StringBuilder logTextBuilder) {
String level = logEntry.getNativeLogger().getLevel().name();
if (displayLength == DISPLAY_LENGTH_UNSET) {
logTextBuilder.append(level);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import elf4j.impl.core.service.LogEntry;
import elf4j.impl.core.util.StackTraceUtils;
import lombok.NonNull;
import lombok.Value;

import javax.annotation.Nonnull;
Expand Down Expand Up @@ -59,7 +60,7 @@ public boolean includeCallerThread() {
}

@Override
public void render(LogEntry logEntry, StringBuilder logTextBuilder) {
public void render(@NonNull LogEntry logEntry, @NonNull StringBuilder logTextBuilder) {
logTextBuilder.append(logEntry.getResolvedMessage());
Throwable t = logEntry.getException();
if (t == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
package elf4j.impl.core.writer.pattern;

import elf4j.impl.core.service.LogEntry;
import lombok.NonNull;
import lombok.Value;

import javax.annotation.Nonnull;
Expand Down Expand Up @@ -59,7 +60,7 @@ public boolean includeCallerThread() {
}

@Override
public void render(LogEntry logEntry, StringBuilder logTextBuilder) {
public void render(@NonNull LogEntry logEntry, @NonNull StringBuilder logTextBuilder) {
logTextBuilder.append(Objects.requireNonNull(logEntry.getCallerFrame()).getMethodName());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ static Optional<String> getPatternSegmentOption(@NonNull String patternSegment)
* final log message.
* @return ordered list of individual patterns forming the entire layout pattern of the writer
*/
static List<LogPattern> parsePatternSegments(@NonNull String pattern) {
static @NonNull List<LogPattern> parsePatternSegments(@NonNull String pattern) {
if (pattern.trim().isEmpty()) {
throw new IllegalArgumentException("Unexpected blank pattern");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public boolean includeCallerThread() {
}

@Override
public void render(LogEntry logEntry, StringBuilder logTextBuilder) {
public void render(@NonNull LogEntry logEntry, @NonNull StringBuilder logTextBuilder) {
LogEntry.ThreadInformation callerThread = Objects.requireNonNull(logEntry.getCallerThread());
logTextBuilder.append(threadDisplayOption == DisplayOption.ID ? callerThread.getId() : callerThread.getName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public boolean includeCallerThread() {
}

@Override
public void render(LogEntry logEntry, StringBuilder logTextBuilder) {
public void render(@NonNull LogEntry logEntry, @NonNull StringBuilder logTextBuilder) {
logTextBuilder.append(dateTimeFormatter.format(logEntry.getTimestamp()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public boolean includeCallerThread() {
}

@Override
public void render(LogEntry logEntry, StringBuilder logTextBuilder) {
public void render(LogEntry logEntry, @NonNull StringBuilder logTextBuilder) {
logTextBuilder.append(text);
}
}

0 comments on commit 453dc0b

Please sign in to comment.