yu.ac.bg.etf.javaqx.logging
Class Logger

java.lang.Object
  extended byyu.ac.bg.etf.javaqx.logging.Logger

public final class Logger
extends java.lang.Object

Very simple logging API facade. It supports Java 1.4 logging API, Apache Log4J API and implements its own simple logging API.

Version:
0.2.0
Author:
Slobodan Vrkacevic (slobodan.vrkacevic@gmail.com)

Field Summary
static int LEVEL_ERROR
          Error logging level (the value is 2).
static int LEVEL_INFO
          Information logging level (the value is 0).
static int LEVEL_WARN
          Warning logging level (the value is 1).
 
Method Summary
static LoggingAdapter getLoggingAdapter()
          Returns current logging API adapter.
static boolean isEnabled()
          Returns true if the logger is enabled.
static boolean isErrorEnabled()
          Returns true it error logging is enabled.
static boolean isInfoEnabled()
          Returns true it information logging is enabled.
static boolean isLevelEnabled(int level)
          Returns true if logging on the specified level is enabled.
static boolean isWarningEnabled()
          Returns true it warning logging is enabled.
static void log(int level, java.lang.String message)
          Logs a message.
static void log(int level, java.lang.String fileName, int lineNumber, java.lang.String message)
          Logs a message.
static void log(int level, java.lang.String fileName, int lineNumber, java.lang.String message, java.lang.Throwable t)
          Logs a message.
static void log(int level, java.lang.String fileName, int lineNumber, java.lang.Throwable t)
          Logs a message.
static void log(int level, java.lang.String message, java.lang.Throwable t)
          Logs a message.
static void log(int level, java.lang.Throwable t)
          Logs a message.
static void logError(java.lang.String message)
          Logs an error message.
static void logError(java.lang.String message, java.lang.Throwable t)
          Logs an error message.
static void logError(java.lang.Throwable t)
          Logs an error throwable.
static void logInfo(java.lang.String message)
          Logs an information message.
static void logWarning(java.lang.String message)
          Logs a warning message.
static void logWarning(java.lang.String message, java.lang.Throwable t)
          Logs a warning message.
static void logWarning(java.lang.Throwable t)
          Logs a warning throwable.
static void setEnabled(boolean enabled)
          Enables/disables the logger.
static void setLoggingAdapter(LoggingAdapter loggingAdapter)
          Sets current logging API adapter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LEVEL_INFO

public static final int LEVEL_INFO
Information logging level (the value is 0).

See Also:
Constant Field Values

LEVEL_WARN

public static final int LEVEL_WARN
Warning logging level (the value is 1).

See Also:
Constant Field Values

LEVEL_ERROR

public static final int LEVEL_ERROR
Error logging level (the value is 2).

See Also:
Constant Field Values
Method Detail

getLoggingAdapter

public static LoggingAdapter getLoggingAdapter()
Returns current logging API adapter.

Returns:
current logging API adapter

setLoggingAdapter

public static void setLoggingAdapter(LoggingAdapter loggingAdapter)
Sets current logging API adapter.

Parameters:
loggingAdapter - the logging API adapter
Throws:
java.lang.IllegalArgumentException - if the logging adapter is null

isEnabled

public static boolean isEnabled()
Returns true if the logger is enabled.

Returns:
true if the logger is enabled

setEnabled

public static void setEnabled(boolean enabled)
Enables/disables the logger.

Parameters:
enabled - if true the logger is enabled

isLevelEnabled

public static boolean isLevelEnabled(int level)
Returns true if logging on the specified level is enabled.

Parameters:
level - the logging level
Returns:
true if logging on the specified level is enabled

log

public static void log(int level,
                       java.lang.String message,
                       java.lang.Throwable t)
Logs a message.

Parameters:
level - the logging level
message - the message
t - the throwable

log

public static void log(int level,
                       java.lang.String message)
Logs a message.

Parameters:
level - the logging level
message - the message

log

public static void log(int level,
                       java.lang.Throwable t)
Logs a message.

Parameters:
level - the logging level
t - the throwable

log

public static void log(int level,
                       java.lang.String fileName,
                       int lineNumber,
                       java.lang.String message,
                       java.lang.Throwable t)
Logs a message.

Parameters:
level - the logging level
fileName - the file name
lineNumber - the line number
message - the message
t - the throwable

log

public static void log(int level,
                       java.lang.String fileName,
                       int lineNumber,
                       java.lang.String message)
Logs a message.

Parameters:
level - the logging level
fileName - the file name
lineNumber - the line number
message - the message

log

public static void log(int level,
                       java.lang.String fileName,
                       int lineNumber,
                       java.lang.Throwable t)
Logs a message.

Parameters:
level - the logging level
fileName - the file name
lineNumber - the line number
t - the throwable

isErrorEnabled

public static boolean isErrorEnabled()
Returns true it error logging is enabled.

Returns:
true it error logging is enabled

logError

public static void logError(java.lang.String message,
                            java.lang.Throwable t)
Logs an error message.

Parameters:
message - the error message
t - the throwable to log

logError

public static void logError(java.lang.String message)
Logs an error message.

Parameters:
message - the error message

logError

public static void logError(java.lang.Throwable t)
Logs an error throwable.

Parameters:
t - the throwable to log

isWarningEnabled

public static boolean isWarningEnabled()
Returns true it warning logging is enabled.

Returns:
true it warning logging is enabled

logWarning

public static void logWarning(java.lang.String message,
                              java.lang.Throwable t)
Logs a warning message.

Parameters:
message - the warning message
t - the throwable to log

logWarning

public static void logWarning(java.lang.String message)
Logs a warning message.

Parameters:
message - the warning message

logWarning

public static void logWarning(java.lang.Throwable t)
Logs a warning throwable.

Parameters:
t - the throwable to log

isInfoEnabled

public static boolean isInfoEnabled()
Returns true it information logging is enabled.

Returns:
true it information logging is enabled

logInfo

public static void logInfo(java.lang.String message)
Logs an information message.

Parameters:
message - the information message


Copyright © 2007 ETF and contributors. All Rights Reserved.