[Arakhnę-Dev] [14] First public release of arakhneLogger

[ Thread Index | Date Index | More arakhne.org/dev Archives ]


Revision: 14
Author:   galland
Date:     2008-12-06 15:36:28 +0100 (Sat, 06 Dec 2008)

Log Message:
-----------
First public release of arakhneLogger

Added Paths:
-----------
    trunk/arakhneLogger/
    trunk/arakhneLogger/src/
    trunk/arakhneLogger/src/main/
    trunk/arakhneLogger/src/main/java/
    trunk/arakhneLogger/src/main/java/org/
    trunk/arakhneLogger/src/main/java/org/arakhne/
    trunk/arakhneLogger/src/main/java/org/arakhne/logging/
    trunk/arakhneLogger/src/main/java/org/arakhne/logging/AbstractLogger.java


Added: trunk/arakhneLogger/src/main/java/org/arakhne/logging/AbstractLogger.java
===================================================================
--- trunk/arakhneLogger/src/main/java/org/arakhne/logging/AbstractLogger.java	                        (rev 0)
+++ trunk/arakhneLogger/src/main/java/org/arakhne/logging/AbstractLogger.java	2008-12-06 14:36:28 UTC (rev 14)
@@ -0,0 +1,155 @@
+/* 
+ * $Id$
+ * 
+ * Copyright (C) 2004-2008 Stéphane GALLAND and Nicolas GAUD
+ * 
+ * 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 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * This program is free software; you can redistribute it and/or modify
+ */
+package org.arakhne.logging;
+
+/**
+ * This class provides the concrete implementation of the <code>Logger</code>
+ * interface. This impl is based on the Sun's Logging Facade for Java
+ * 
+ * @author St&eacute;phane GALLAND &lt;galland@xxxxxxxxxxx&gt;
+ * @version $Name$ $Revision$ $Date$
+ * @see Logger
+ */
+public abstract class AbstractLogger implements Logger {
+
+	private LogLevel minLevel;
+	
+	/**
+	 */
+	public AbstractLogger() {
+		this.minLevel = null;
+	}
+	
+	/** Check if logging is allowed.
+	 * 
+	 * @param requestedLevel is the level to check.
+	 * @return <code>true</code> if logging is allowed, <code>false</code> otherwise
+	 */
+	protected final boolean isLoggableFor(LogLevel requestedLevel) {
+		return requestedLevel.hasHigherPriority(getLogLevel());
+	}	
+
+	/** 
+	 * {@inheritDoc}
+	 */
+	public void setLogLevel(LogLevel level) {
+		this.minLevel = level;
+	}
+
+	/** 
+	 * {@inheritDoc}
+	 */
+	public final LogLevel getLogLevel() {
+		if (this.minLevel==null) return LoggingSystem.getLoggingSystem().getDefaultLogLevel(); 
+		return this.minLevel;
+	}
+
+	/** {@InheritDoc}
+	 * 
+	 * @param arg0 {@InheritDoc}
+	 * @param arg1 {@InheritDoc}
+	 */
+	public final void debug(String arg0, Throwable arg1) {
+		log(LogLevel.DEBUG,arg0,arg1);
+	}
+
+	/** 
+	 * {@inheritDoc}
+	 */
+	public final void debug(String arg0) {
+		log(LogLevel.DEBUG,arg0);
+	}
+
+	/** 
+	 * {@inheritDoc}
+	 */
+	public final void error(String arg0, Throwable arg1) {
+		log(LogLevel.ERROR,arg0,arg1);
+	}
+
+	/** 
+	 * {@inheritDoc}
+	 */
+	public final void error(String arg0) {
+		log(LogLevel.ERROR,arg0);
+	}
+
+	/** 
+	 * {@inheritDoc}
+	 */
+	public final void info(String arg0, Throwable arg1) {
+		log(LogLevel.INFO,arg0,arg1);
+	}
+
+	/** 
+	 * {@inheritDoc}
+	 */
+	public final void info(String arg0) {
+		log(LogLevel.INFO,arg0);
+	}
+
+	/** 
+	 * {@inheritDoc}
+	 */
+	public final void warn(String arg0, Throwable arg1) {
+		log(LogLevel.WARNING,arg0,arg1);
+	}
+
+	/** 
+	 * {@inheritDoc}
+	 */
+	public final void warn(String arg0) {
+		log(LogLevel.WARNING,arg0);
+	}
+
+	/** {@InheritDoc}
+	 * 
+	 * @return {@InheritDoc}
+	 */
+	public boolean isDebugEnabled() {
+		return isLoggableFor(LogLevel.DEBUG);
+	}
+
+	/** {@InheritDoc}
+	 * 
+	 * @return {@InheritDoc}
+	 */
+	public boolean isErrorEnabled() {
+		return isLoggableFor(LogLevel.ERROR);
+	}
+
+	/** {@InheritDoc}
+	 * 
+	 * @return {@InheritDoc}
+	 */
+	public boolean isInfoEnabled() {
+		return isLoggableFor(LogLevel.INFO);
+	}
+
+	/** {@InheritDoc}
+	 * 
+	 * @return {@InheritDoc}
+	 */
+	public boolean isWarnEnabled() {
+		return isLoggableFor(LogLevel.WARNING);
+	}
+
+}


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/