Skip to content

Commit

Permalink
Swap System.Logger API with slf4j-api.
Browse files Browse the repository at this point in the history
  • Loading branch information
renatoathaydes committed Jan 16, 2022
1 parent 948cc2e commit f523880
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
8 changes: 4 additions & 4 deletions benchmark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ set -e
#

COMMANDS=(
"java -Djava.util.logging.config.file=log-config/jul.properties -cp build/java Main" # Java (JUL)
"java -Djava.util.logging.manager=org.apache.logging.log4j.jul.LogManager -cp build/java:log-config:log4j-libs/* Main" # Java (Log4j2)
"java -Djava.util.logging.config.file=log-config/jul-logback.properties -cp build/java:log-config:logback-libs/* Main" # Java (Logback)
"java -Djava.util.logging.config.file=log-config/jul.properties -cp build/java:jul-libs/*:build/java:logback-libs/slf4j-api-1.7.33.jar Main" # Java (JUL)
"java -cp build/java:logback-libs/slf4j-api-1.7.33.jar:log-config:log4j-libs/* Main" # Java (Log4j2)
"java -cp build/java:log-config:logback-libs/* Main" # Java (Logback)
)

echo "Compiling Java sources"
rm -rf build || true
javac src/java/*.java -d build/java
javac -cp logback-libs/slf4j-api-1.7.33.jar src/java/*.java -d build/java
javac src/java/util/*.java -d build/util

echo "Compiling Rust sources"
Expand Down
Binary file added jul-libs/slf4j-jdk14-1.7.33.jar
Binary file not shown.
Binary file added log4j-libs/log4j-slf4j-impl-2.17.1.jar
Binary file not shown.
Binary file added log4j-libs/slf4j-api-1.7.25.jar
Binary file not shown.
7 changes: 4 additions & 3 deletions src/java/Main.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.slf4j.LoggerFactory;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
Expand All @@ -12,7 +14,6 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static java.lang.System.Logger.Level.INFO;
import static java.nio.charset.StandardCharsets.US_ASCII;

/**
Expand All @@ -26,13 +27,13 @@ public static void main( String[] args ) throws IOException {
.parse( new File( args.length > 0 ? args[ 0 ] : "tests/words.txt" ) );

var encoder = new PhoneNumberEncoder( words );
var logger = System.getLogger( "Main" );
var logger = LoggerFactory.getLogger( "Main" );

new InputParser( PhoneNumberCleaner::clean )
.parse( new File( args.length > 1 ? args[ 1 ] : "tests/numbers.txt" ) )
.forEach( phone ->
encoder.encode( phone, item -> {
logger.log( INFO, "{0}: {1}", item.original(), item.result() );
logger.info( "{}: {}", item.original(), item.result() );
} ) );

}
Expand Down

0 comments on commit f523880

Please sign in to comment.