com.tapstream.sdk.Logging Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tapstream-core Show documentation
Show all versions of tapstream-core Show documentation
This library contains the building blocks for a Tapstream Java SDK
package com.tapstream.sdk;
public class Logging {
public static final int INFO = 4;
public static final int WARN = 5;
public static final int ERROR = 6;
public interface Logger {
void log(int logLevel, String msg);
}
private static class DefaultLogger implements Logger {
@Override
public void log(int logLevel, String msg) {
System.out.println(msg);
}
}
private static Logger logger = null;
synchronized public static void setLogger(Logger logger) {
Logging.logger = logger;
}
synchronized public static boolean isConfigured(){
return logger != null;
}
synchronized public static void log(int logLevel, String format, Object... args) {
if (logger == null){
logger = new DefaultLogger();
}
try {
String msg = format == null ? null : String.format(format, args);
logger.log(logLevel, msg);
} catch (Exception e){
logger.log(ERROR, "Unhandled exception in the logging system. " +
"This should never happen.");
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy