aboutsummaryrefslogtreecommitdiff
path: root/common/src/main/java/at/gv/egovernment/moa/logging/Logger.java
diff options
context:
space:
mode:
authormcentner <mcentner@d688527b-c9ab-4aba-bd8d-4036d912da1d>2007-08-08 07:25:32 +0000
committermcentner <mcentner@d688527b-c9ab-4aba-bd8d-4036d912da1d>2007-08-08 07:25:32 +0000
commit43e57a42832ea8b4ceb0317f3c9028a4174ffa7b (patch)
treef5ed9074b8d7b89b2dd5b22d326f63be103e7551 /common/src/main/java/at/gv/egovernment/moa/logging/Logger.java
parent10889e9dea2cc2f70b475e6ff7af37fdba1621d9 (diff)
downloadmoa-id-spss-43e57a42832ea8b4ceb0317f3c9028a4174ffa7b.tar.gz
moa-id-spss-43e57a42832ea8b4ceb0317f3c9028a4174ffa7b.tar.bz2
moa-id-spss-43e57a42832ea8b4ceb0317f3c9028a4174ffa7b.zip
Adapted project directory structure to suit the new maven based build process.
git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@909 d688527b-c9ab-4aba-bd8d-4036d912da1d
Diffstat (limited to 'common/src/main/java/at/gv/egovernment/moa/logging/Logger.java')
-rw-r--r--common/src/main/java/at/gv/egovernment/moa/logging/Logger.java175
1 files changed, 175 insertions, 0 deletions
diff --git a/common/src/main/java/at/gv/egovernment/moa/logging/Logger.java b/common/src/main/java/at/gv/egovernment/moa/logging/Logger.java
new file mode 100644
index 000000000..eb7aa5634
--- /dev/null
+++ b/common/src/main/java/at/gv/egovernment/moa/logging/Logger.java
@@ -0,0 +1,175 @@
+package at.gv.egovernment.moa.logging;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * A utility class acting as a facade to the logging subsystem.
+ *
+ * Configure the logging defaultHierarchy that the <code>Logger</code> uses by
+ * calling <code>setHierarchy</code> once before calling any of the logging
+ * output functions.
+ *
+ * @author Patrick Peck
+ * @version $Id$
+ */
+public class Logger {
+
+ /** The default logging hierarchy. */
+ private static String defaultHierarchy = "";
+
+ /**
+ * Get the <code>Log</code> object for the default hierarchy.
+ *
+ * @return The <code>Log</code> object to write log messages to.
+ */
+ private static Log getLog() {
+ return LogFactory.getLog(defaultHierarchy);
+ }
+
+ /**
+ * Get the <code>Log</code> object for a given hierarchy.
+ *
+ * @param hierarchy The logging hierarchy for which to return the logger.
+ * @return The <code>Log</code> object to write log messages to.
+ */
+ private static Log getLog(String hierarchy) {
+ return LogFactory.getLog(hierarchy);
+ }
+
+ /**
+ * Set the default hierarchy to which the <code>Logger</code> should send its
+ * logging output.
+ * @param hierarchy The logging defaultHierarchy.
+ */
+ public static void setHierarchy(String hierarchy) {
+ defaultHierarchy = hierarchy;
+ }
+
+ /**
+ * Test, if the trace log level is enabled.
+ *
+ * @return boolean <code>true</code>, if tracing output is enabled
+ * <code>false</code> otherwise.
+ */
+ public static boolean isTraceEnabled() {
+ return getLog().isTraceEnabled();
+ }
+
+ /**
+ * Test, if the trace log level is enabled for a given hierarchy.
+ *
+ * @param hierarchy requested log hierarchy
+ * @return boolean <code>true</code>, if tracing output is enabled
+ * <code>false</code> otherwise.
+ */
+ public static boolean isTraceEnabled(String hierarchy) {
+ return getLog(hierarchy).isTraceEnabled();
+ }
+
+ /**
+ * Trace a message.
+ *
+ * @param message The message to trace.
+ */
+ public static void trace(Object message) {
+ getLog().trace(message);
+ }
+
+ /**
+ * Test, if the debug log level is enabled.
+ *
+ * @return boolean <code>true</code>, if debug output is enabled
+ * <code>false</code> otherwise.
+ */
+ public static boolean isDebugEnabled() {
+ return getLog().isDebugEnabled();
+ }
+
+ /**
+ * Test, if the debug log level is enabled for a given hierarchy.
+ *
+ * @param hierarchy requested log hierarchy
+ * @return boolean <code>true</code>, if debug output is enabled
+ * <code>false</code> otherwise.
+ */
+ public static boolean isDebugEnabled(String hierarchy) {
+ return getLog(hierarchy).isDebugEnabled();
+ }
+
+ /**
+ * Log a debug message.
+ *
+ * @param message The message to log.
+ */
+ public static void debug(Object message) {
+ getLog().debug(message);
+ }
+
+ /**
+ * Log an info message.
+ *
+ * @param message The message to log.
+ */
+ public static void info(Object message) {
+ getLog().info(message);
+ }
+
+ /**
+ * Log a warning message.
+ *
+ * @param message The message to log.
+ */
+ public static void warn(Object message) {
+ getLog().warn(message);
+ }
+
+ /**
+ * Log a warning message.
+ *
+ * @param message The message to log.
+ * @param t An exception that may be the cause of the warning.
+ */
+ public static void warn(Object message, Throwable t) {
+ getLog().warn(message, t);
+ }
+
+ /**
+ * Log an error message.
+ *
+ * @param message The message to log.
+ */
+ public static void error(Object message) {
+ getLog().error(message);
+ }
+
+ /**
+ * Log an error message.
+ *
+ * @param message The message to log.
+ * @param t An exception that may be the cause of the error.
+ */
+ public static void error(Object message, Throwable t) {
+ getLog().error(message, t);
+ }
+
+ /**
+ * Log a fatal error message.
+ *
+ * @param message The message to log.
+ */
+ public static void fatal(Object message) {
+ getLog().fatal(message);
+ }
+
+ /**
+ * Log a fatal error message.
+ *
+ * @param message The message to log.
+ * @param t An exception that may be the cause of the error.
+ */
+ public static void fatal(Object message, Throwable t) {
+ getLog().fatal(message, t);
+ }
+
+}