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

org.coos.messaging.util.DefaultLogger Maven / Gradle / Ivy

/**
 * COOS - Connected Objects Operating System (www.connectedobjects.org).
 *
 * Copyright (C) 2009 Telenor ASA and Tellu AS. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This library is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published
 * by the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see .
 *
 * You may also contact one of the following for additional information:
 * Telenor ASA, Snaroyveien 30, N-1331 Fornebu, Norway (www.telenor.no)
 * Tellu AS, Hagalokkveien 13, N-1383 Asker, Norway (www.tellu.no)
 */
package org.coos.messaging.util;

import java.util.Date;

/**
 * This class is a logger class used in environments where j2se is not available
 * 
 * @author Knut Eilif Husa, Tellu AS
 * 
 */
public class DefaultLogger implements Log {

	public static final int TRACE = 1;
	public static final int DEBUG = 2;
	public static final int INFO = 3;
	public static final int WARN = 4;
	public static final int ERROR = 5;
	public static final int FATAL = 6;

	private String name = "";
	private static int level = 1;

	public DefaultLogger(String loggerName) {
		this.name = loggerName;
	}

	public static int getLevel() {
		return level;
	}

	public static void setLevel(int level) {
		DefaultLogger.level = level;
	}

	public void setLoggerName(String loggerName) {
		name = loggerName;
	}

	public void trace(String arg) {
		if (level <= TRACE) {
			StringBuffer buf = new StringBuffer();
			buf.append(new Date());
			buf.append(":[TRACE]:");
			buf.append(arg);
			System.out.println(buf.toString());
		}

	}

	public void debug(String arg) {
		if (level <= DEBUG) {
			StringBuffer buf = new StringBuffer();
			buf.append(new Date());
			buf.append(":[DEBUG]:");
			buf.append(arg);
			System.out.println(buf.toString());
		}
	}

	public void info(String arg) {
		if (level <= INFO) {
			StringBuffer buf = new StringBuffer();
			buf.append(new Date());
			buf.append(":[INFO]:");
			buf.append(arg);
			System.out.println(buf.toString());
		}

	}

	public void warn(String arg) {
		if (level <= WARN) {
			StringBuffer buf = new StringBuffer();
			buf.append(new Date());
			buf.append(":[WARNING]:");
			buf.append(arg);
			System.out.println(buf.toString());
		}

	}

	public void error(String arg) {
		if (level <= ERROR) {
			StringBuffer buf = new StringBuffer();
			buf.append(new Date());
			buf.append(":[ERROR]:");
			buf.append(arg);
			System.err.println(buf.toString());
		}

	}

	public void putMDC(String key, String value) {
		// No support for MDC
	}

	public void removeMDC(String key) {
		// No support for MDC
	}

	public boolean isInheritMDC() {
		// No support for MDC
		return false;
	}

	public void setInheritMDC(boolean inheritMDC) {
		// No support for MDC
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy