aboutsummaryrefslogtreecommitdiff
path: root/common/src/main/java/at/gv/egovernment/moa
diff options
context:
space:
mode:
Diffstat (limited to 'common/src/main/java/at/gv/egovernment/moa')
-rw-r--r--common/src/main/java/at/gv/egovernment/moa/logging/Logger.java31
1 files changed, 22 insertions, 9 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
index 265ad026d..7cb2e7daf 100644
--- a/common/src/main/java/at/gv/egovernment/moa/logging/Logger.java
+++ b/common/src/main/java/at/gv/egovernment/moa/logging/Logger.java
@@ -79,6 +79,19 @@ public class Logger {
}
/**
+ * Prepare the message for printing it as string.
+ * <p>Mainly introduce because the <code>message</code> might be <code>null</code>.
+ *
+ * @param message the message
+ * @return the string
+ */
+ private static String prepareMessage(Object message) {
+ if(null == message)
+ return "no message given";
+ return message.toString();
+ }
+
+ /**
* Test, if the trace log level is enabled.
*
* @return boolean <code>true</code>, if tracing output is enabled
@@ -108,7 +121,7 @@ public class Logger {
*/
public static void trace(Object message) {
org.slf4j.Logger logger = getLogger();
- logger.trace(message.toString());
+ logger.trace(prepareMessage(message));
}
/**
@@ -141,17 +154,17 @@ public class Logger {
*/
public static void debug(Object message) {
org.slf4j.Logger logger = getLogger();
- logger.debug(message.toString());
+ logger.debug(prepareMessage(message));
}
-
- /**
+
+/**
* Log an info message.
*
* @param message The message to log.
*/
public static void info(Object message) {
org.slf4j.Logger logger = getLogger();
- logger.info(message.toString());
+ logger.info(prepareMessage(message));
}
/**
@@ -161,7 +174,7 @@ public class Logger {
*/
public static void warn(Object message) {
org.slf4j.Logger logger = getLogger();
- logger.warn(message.toString());
+ logger.warn(prepareMessage(message));
}
/**
@@ -172,7 +185,7 @@ public class Logger {
*/
public static void warn(Object message, Throwable t) {
org.slf4j.Logger logger = getLogger();
- logger.warn(message.toString(), t);
+ logger.warn(prepareMessage(message), t);
}
/**
@@ -182,7 +195,7 @@ public class Logger {
*/
public static void error(Object message) {
org.slf4j.Logger logger = getLogger();
- logger.error(message.toString());
+ logger.error(prepareMessage(message));
}
/**
@@ -193,7 +206,7 @@ public class Logger {
*/
public static void error(Object message, Throwable t) {
org.slf4j.Logger logger = getLogger();
- logger.error(message.toString(), t);
+ logger.error(prepareMessage(message), t);
}
/**