All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.tapstream.sdk.Logging Maven / Gradle / Ivy

There is a newer version: 4.0.0
Show newest version
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