
io.jsync.app.core.Logger Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jsync.io Show documentation
Show all versions of jsync.io Show documentation
jsync.io is a non-blocking, event-driven networking framework for Java
package io.jsync.app.core;
import io.jsync.logging.impl.LoggerFactory;
public class Logger {
private io.jsync.logging.Logger defaultLogger;
public Logger() {
defaultLogger = LoggerFactory.getLogger(Logger.class);
}
private io.jsync.logging.Logger getLogger() {
io.jsync.logging.Logger logger = defaultLogger;
try {
StackTraceElement[] elements = Thread.currentThread().getStackTrace();
String callingClassName = elements[3].getClassName().replaceAll("\\$[0-9]", "");
logger = LoggerFactory.getLogger(callingClassName);
} catch (Exception ignored) {
}
return logger;
}
public void fatal(final String message) {
getLogger().fatal(message, new Exception(message));
// We want to exit upon a fatal error
System.exit(-1);
}
public void error(String message) {
error(message, null);
}
public void error(String message, Exception throwException) {
if (throwException != null) {
getLogger().error(message, throwException);
return;
}
getLogger().error(message);
}
public void warn(String message) {
getLogger().warn(message);
}
public void info(String message) {
getLogger().info(message);
}
public void debug(String message) {
getLogger().debug(message);
}
public void trace(String message) {
getLogger().trace(message);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy