diff options
Diffstat (limited to 'common-logging/src/main/java')
6 files changed, 463 insertions, 64 deletions
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/OnapLoggingUtils.java b/common-logging/src/main/java/org/onap/policy/common/logging/OnapLoggingUtils.java index 6c0879ea..9bfbe68d 100644 --- a/common-logging/src/main/java/org/onap/policy/common/logging/OnapLoggingUtils.java +++ b/common-logging/src/main/java/org/onap/policy/common/logging/OnapLoggingUtils.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP-Logging * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -60,4 +60,41 @@ public class OnapLoggingUtils { return requestContext; } + /** + * Create message text replace {} place holder with data + * if last argument is throwable/exception, pass it as argument to logger. + * @param format message format can contains text and {} + * @param arguments output arguments + * @return + */ + public static String formatMessage(String format, Object ...arguments) { + if (arguments.length <= 0 || arguments[0] == null) { + return format; + } + int index; + StringBuilder builder = new StringBuilder(); + String[] token = format.split("[{][}]"); + for (index = 0; index < arguments.length; index++) { + if (index < token.length) { + builder.append(token[index]); + builder.append(arguments[index]); + } else { + break; + } + } + for (int index2 = index; index2 < token.length; index2++) { + builder.append(token[index2]); + } + + return builder.toString(); + } + + /** + * Check object is throwable. + * @param obj to verify + * @return true if object is throwable or false otherwise + */ + public static boolean isThrowable(Object obj) { + return (obj instanceof Throwable); + } } diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/PolicyLogger.java b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/PolicyLogger.java index 9e5fd5a6..8de057f9 100644 --- a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/PolicyLogger.java +++ b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/PolicyLogger.java @@ -54,6 +54,7 @@ import java.net.UnknownHostException; import java.text.SimpleDateFormat; import java.time.Duration; import java.time.Instant; +import java.util.Arrays; import java.util.Date; import java.util.Iterator; import java.util.Map; @@ -63,6 +64,7 @@ import java.util.UUID; import java.util.concurrent.ConcurrentMap; import java.util.function.Consumer; import org.apache.commons.lang3.StringUtils; +import org.onap.policy.common.logging.OnapLoggingUtils; import org.onap.policy.common.logging.flexlogger.LoggerType; import org.slf4j.MDC; @@ -331,7 +333,6 @@ public class PolicyLogger { * Set Timestamps for start, end and duration of logging a transaction. */ private static void seTimeStamps() { - MDC.put(MDC_INSTANCE_UUID, ""); MDC.put(MDC_ALERT_SEVERITY, ""); @@ -433,18 +434,6 @@ public class PolicyLogger { } /** - * Records only one String message with its class name. - * - * @param className the class name - * @param arg0 the message - */ - public static void info(String className, String arg0) { - MDC.put(classNameProp, className); - debugLogger.info(MessageCodes.GENERAL_INFO, arg0); - } - - - /** * Records only one String message. * * @param arg0 the message @@ -483,14 +472,29 @@ public class PolicyLogger { } /** - * Records only one String message with its class name. + * Records a message with passed in message text and variable number of arguments. * - * @param arg0 log message - * @param className class name + * @param message class name if one argument, otherwise message text + * @param arguments variable number of arguments */ - public static void warn(String className, String arg0) { - MDC.put(classNameProp, className); - debugLogger.warn(MessageCodes.GENERAL_INFO, arg0); + public static void info(String message, Object... arguments) { + if (!debugLogger.isInfoEnabled()) { + return; + } + if (arguments.length == 1 && !OnapLoggingUtils.isThrowable(arguments[0])) { + MDC.put(classNameProp, message); + debugLogger.info(MessageCodes.GENERAL_INFO, + arguments[0] == null ? "" : arguments[0].toString()); + return; + } + if (arguments.length == 1 && OnapLoggingUtils.isThrowable(arguments[0])) { + String arguments2 = getNormalizedStackTrace((Throwable)arguments[0], ""); + debugLogger.info(MessageCodes.GENERAL_INFO, message + arguments2); + return; + } + + MDC.put(classNameProp, ""); + debugLogger.info(message, arguments); } /** @@ -553,15 +557,28 @@ public class PolicyLogger { } /** - * Records only one String message with its class name. + * Records a message with passed in message text and variable number of arguments. * - * @param className class name - * @param arg0 log message + * @param message class name if one argument, otherwise message text + * @param arguments variable number of arguments */ - public static void error(String className, String arg0) { - MDC.put(classNameProp, className); - setErrorCode(MessageCodes.GENERAL_ERROR); - errorLogger.error(MessageCodes.GENERAL_ERROR, arg0); + public static void warn(String message, Object... arguments) { + if (!debugLogger.isWarnEnabled()) { + return; + } + if (arguments.length == 1 && !OnapLoggingUtils.isThrowable(arguments[0])) { + MDC.put(classNameProp, message); + debugLogger.warn(MessageCodes.GENERAL_INFO, + arguments[0] == null ? "" : arguments[0].toString()); + return; + } + if (arguments.length == 1 && OnapLoggingUtils.isThrowable(arguments[0])) { + String arguments2 = getNormalizedStackTrace((Throwable)arguments[0], ""); + debugLogger.warn(MessageCodes.GENERAL_INFO, message + arguments2); + return; + } + MDC.put(classNameProp, ""); + debugLogger.warn(message, arguments); } /** @@ -629,25 +646,41 @@ public class PolicyLogger { } /** - * Records a message with passed in message code and a list of string values. + * Records a message with passed in message text and variable number of arguments. * - * @param msg the message code - * @param arguments the messages + * @param message class name if one argument, otherwise message text + * @param arguments variable number of arguments */ - public static void debug(MessageCodes msg, String... arguments) { + public static void error(String message, Object... arguments) { + if (!errorLogger.isErrorEnabled()) { + return; + } + if (arguments.length == 1 && !OnapLoggingUtils.isThrowable(arguments[0])) { + MDC.put(classNameProp, message); + setErrorCode(MessageCodes.GENERAL_ERROR); + errorLogger.error(MessageCodes.GENERAL_ERROR, + arguments[0] == null ? "" : arguments[0].toString()); + return; + } + if (arguments.length == 1 && OnapLoggingUtils.isThrowable(arguments[0])) { + String arguments2 = getNormalizedStackTrace((Throwable)arguments[0], ""); + errorLogger.error(MessageCodes.GENERAL_ERROR, message + arguments2); + return; + } MDC.put(classNameProp, ""); - debugLogger.debug(msg, arguments); + setErrorCode(MessageCodes.GENERAL_ERROR); + errorLogger.error(message, arguments); } /** - * Records only one String message with its class name. + * Records a message with passed in message code and a list of string values. * - * @param className the class name - * @param arg0 the message + * @param msg the message code + * @param arguments the messages */ - public static void debug(String className, String arg0) { - MDC.put(classNameProp, className); - debugLogger.debug(MessageCodes.GENERAL_INFO, arg0); + public static void debug(MessageCodes msg, String... arguments) { + MDC.put(classNameProp, ""); + debugLogger.debug(msg, arguments); } /** @@ -700,17 +733,28 @@ public class PolicyLogger { } /** - * Records only one String message with its class name. + * Records a message with passed in message text and variable number of arguments. * - * @param className the class name - * @param arg0 the message + * @param message class name if one argument, otherwise message text + * @param arguments variable number of arguments */ - public static void audit(String className, Object arg0) { - MDC.put(INVOCATION_ID, MDC.get(MDC_KEY_REQUEST_ID)); - MDC.put(STATUS_CODE, COMPLETE_STATUS); - MDC.put(RESPONSE_CODE, "0"); - MDC.put(classNameProp, className); - auditLogger.info("" + arg0); + public static void debug(String message, Object... arguments) { + if (!debugLogger.isDebugEnabled()) { + return; + } + if (arguments.length == 1 && !OnapLoggingUtils.isThrowable(arguments[0])) { + MDC.put(classNameProp, message); + debugLogger.debug(MessageCodes.GENERAL_INFO, + arguments[0] == null ? "" : arguments[0].toString()); + return; + } + if (arguments.length == 1 && OnapLoggingUtils.isThrowable(arguments[0])) { + String arguments2 = getNormalizedStackTrace((Throwable)arguments[0], ""); + debugLogger.debug(MessageCodes.GENERAL_INFO, message + arguments2); + return; + } + MDC.put(classNameProp, ""); + debugLogger.debug(message, arguments); } /** @@ -727,6 +771,29 @@ public class PolicyLogger { } /** + * Records a message with passed in message text and variable number of arguments. + * + * @param message class name if one argument, otherwise message text + * @param arguments variable number of arguments + */ + public static void audit(String message, Object... arguments) { + if (!auditLogger.isInfoEnabled()) { + return; + } + MDC.put(INVOCATION_ID, postMdcInfoForEvent(null)); + MDC.put(STATUS_CODE, COMPLETE_STATUS); + MDC.put(RESPONSE_CODE, "0"); + if (arguments.length == 1 && !OnapLoggingUtils.isThrowable(arguments[0])) { + MDC.put(classNameProp, message); + auditLogger.info(arguments[0] == null ? "" : arguments[0].toString()); + return; + } + + MDC.put(classNameProp, ""); + auditLogger.info(message, arguments); + } + + /** * returns true for enabled, false for not enabled. */ public static boolean isDebugEnabled() { @@ -1093,6 +1160,7 @@ public class PolicyLogger { * @param arg0 the message */ public static void metrics(String arg0) { + seTimeStamps(); MDC.put(INVOCATION_ID, MDC.get(MDC_KEY_REQUEST_ID)); MDC.put(RESPONSE_CODE, "0"); String serviceName = MDC.get(MDC_SERVICE_NAME); @@ -1100,31 +1168,47 @@ public class PolicyLogger { } /** - * Records the metrics event with a class name and a String message. + * Records the metrics event with a String message. * * @param arg0 the message */ - public static void metrics(String className, Object arg0) { + public static void metrics(Object arg0) { seTimeStamps(); MDC.put(INVOCATION_ID, MDC.get(MDC_KEY_REQUEST_ID)); MDC.put(RESPONSE_CODE, "0"); - MDC.put(classNameProp, className); + MDC.put(classNameProp, ""); String serviceName = MDC.get(MDC_SERVICE_NAME); metricsLogger.info(MessageCodes.RULE_METRICS_INFO, serviceName, "" + arg0); } /** - * Records the metrics event with a String message. + * Records a message with passed in message text and variable number of arguments. * - * @param arg0 the message + * @param message class name if one argument, otherwise message text + * @param arguments variable number of arguments */ - public static void metrics(Object arg0) { + public static void metrics(String message, Object... arguments) { + if (!metricsLogger.isInfoEnabled()) { + return; + } seTimeStamps(); MDC.put(INVOCATION_ID, MDC.get(MDC_KEY_REQUEST_ID)); MDC.put(RESPONSE_CODE, "0"); + if (arguments.length == 1 && !OnapLoggingUtils.isThrowable(arguments[0])) { + MDC.put(classNameProp, message); + String serviceName = MDC.get(MDC_SERVICE_NAME); + metricsLogger.info(MessageCodes.RULE_METRICS_INFO, serviceName, + arguments[0] == null ? "" : arguments[0].toString()); + return; + } + if (arguments.length == 1 && OnapLoggingUtils.isThrowable(arguments[0])) { + String arguments2 = getNormalizedStackTrace((Throwable)arguments[0], ""); + metricsLogger.info(MessageCodes.RULE_METRICS_INFO, message + arguments2); + return; + } + MDC.put(classNameProp, ""); - String serviceName = MDC.get(MDC_SERVICE_NAME); - metricsLogger.info(MessageCodes.RULE_METRICS_INFO, serviceName, "" + arg0); + metricsLogger.info(message, arguments); } /** diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/EelfLogger.java b/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/EelfLogger.java index a3e5cc8f..df60fa9c 100644 --- a/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/EelfLogger.java +++ b/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/EelfLogger.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP-Logging * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -166,6 +166,17 @@ public class EelfLogger implements Logger, Serializable { } /** + * Records a message. + * + * @param message the message + * @param arguments the arguments for message + */ + @Override + public void debug(String message, Object... arguments) { + PolicyLogger.debug(message, arguments); + } + + /** * Records an error message. * * @param message the message @@ -210,6 +221,17 @@ public class EelfLogger implements Logger, Serializable { } /** + * Records an error message. + * + * @param message the message + * @param arguments the arguments for message + */ + @Override + public void error(String message, Object... arguments) { + PolicyLogger.error(message, arguments); + } + + /** * Records a message. * * @param message the message @@ -234,6 +256,17 @@ public class EelfLogger implements Logger, Serializable { * Records a message. * * @param message the message + * @param arguments the arguments for message + */ + @Override + public void info(String message, Object... arguments) { + PolicyLogger.info(message, arguments); + } + + /** + * Records a message. + * + * @param message the message */ @Override public void warn(Object message) { @@ -278,6 +311,17 @@ public class EelfLogger implements Logger, Serializable { * Records a message. * * @param message the message + * @param arguments the arguments for message + */ + @Override + public void warn(String message, Object... arguments) { + PolicyLogger.warn(message, arguments); + } + + /** + * Records a message. + * + * @param message the message */ @Override public void trace(Object message) { @@ -387,6 +431,17 @@ public class EelfLogger implements Logger, Serializable { } /** + * Records a message. + * + * @param message the message + * @param arguments the arguments for message + */ + @Override + public void audit(String message, Object... arguments) { + PolicyLogger.audit(message, arguments); + } + + /** * Records an audit message. * * @param eventId the event ID @@ -485,6 +540,17 @@ public class EelfLogger implements Logger, Serializable { } /** + * Records a message. + * + * @param message the message + * @param arguments the arguments for message + */ + @Override + public void metrics(String message, Object... arguments) { + PolicyLogger.metrics(message, arguments); + } + + /** * Populates MDC Info. * * @param transId the transaction ID diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/Logger.java b/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/Logger.java index d6f020e0..315cd935 100644 --- a/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/Logger.java +++ b/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/Logger.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP-Logging * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,6 +41,11 @@ public interface Logger { public void debug(Object message, Throwable throwable); /** + * Prints messages with the level.DEBUG + */ + public void debug(String message, Object... arguments); + + /** * Prints messages with the level.ERROR */ public void error(Object message); @@ -61,6 +66,11 @@ public interface Logger { public void error(MessageCodes msg, Throwable arg0, String... arguments); /** + * Prints messages with the level.ERROR + */ + public void error(String message, Object... arguments); + + /** * Prints messages with the level.INFO */ public void info(Object message); @@ -71,6 +81,11 @@ public interface Logger { public void info(Object message, Throwable throwable); /** + * Prints messages with the level.INFO + */ + public void info(String message, Object... arguments); + + /** * Prints messages with the level.WARN */ public void warn(Object message); @@ -91,6 +106,11 @@ public interface Logger { public void warn(MessageCodes msg, Throwable arg0, String... arguments); /** + * Prints messages with the level.WARN + */ + public void warn(String message, Object... arguments); + + /** * Prints messages with the level.TRACE */ public void trace(Object message); @@ -111,6 +131,11 @@ public interface Logger { public void audit(Object arg0, Throwable throwable); /** + * Prints messages in audit log with the level.INFO + */ + public void audit(String message, Object... arguments); + + /** * Records event Id in audit log with the level.INFO */ public void recordAuditEventStart(String eventId); @@ -157,6 +182,11 @@ public interface Logger { public void metrics(Object arg0); /** + * Records the Metrics log message. + */ + public void metrics(String message, Object... arguments); + + /** * Returns a boolean value, true for debug logging enabled, false for not enabled. */ public boolean isDebugEnabled(); diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/Logger4J.java b/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/Logger4J.java index 5af40b09..bb5e1142 100644 --- a/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/Logger4J.java +++ b/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/Logger4J.java @@ -33,6 +33,7 @@ import java.util.UUID; import org.apache.log4j.Logger; import org.apache.log4j.Priority; +import org.onap.policy.common.logging.OnapLoggingUtils; import org.onap.policy.common.logging.eelf.MessageCodes; import org.onap.policy.common.logging.eelf.PolicyLogger; @@ -115,6 +116,21 @@ public class Logger4J implements org.onap.policy.common.logging.flexlogger.Logge } /** + * Records a message. + * + * @param message the message + * @param arguments variable number of arguments + */ + @Override + public void debug(String message, Object... arguments) { + if (arguments.length == 1 && OnapLoggingUtils.isThrowable(arguments[0])) { + log.debug(message, (Throwable)arguments[0]); + } else { + log.debug(OnapLoggingUtils.formatMessage(message, arguments)); + } + } + + /** * Records an error message. * * @param message the message @@ -163,6 +179,21 @@ public class Logger4J implements org.onap.policy.common.logging.flexlogger.Logge * Records a message. * * @param message the message + * @param arguments variable number of arguments + */ + @Override + public void error(String message, Object... arguments) { + if (arguments.length == 1 && OnapLoggingUtils.isThrowable(arguments[0])) { + log.error(message, (Throwable)arguments[0]); + } else { + log.error(OnapLoggingUtils.formatMessage(message, arguments)); + } + } + + /** + * Records a message. + * + * @param message the message */ @Override public void info(Object message) { @@ -184,6 +215,21 @@ public class Logger4J implements org.onap.policy.common.logging.flexlogger.Logge * Records a message. * * @param message the message + * @param arguments variable number of arguments + */ + @Override + public void info(String message, Object... arguments) { + if (arguments.length == 1 && OnapLoggingUtils.isThrowable(arguments[0])) { + log.info(message, (Throwable)arguments[0]); + } else { + log.info(OnapLoggingUtils.formatMessage(message, arguments)); + } + } + + /** + * Records a message. + * + * @param message the message */ @Override public void warn(Object message) { @@ -228,6 +274,21 @@ public class Logger4J implements org.onap.policy.common.logging.flexlogger.Logge * Records a message. * * @param message the message + * @param arguments variable number of arguments + */ + @Override + public void warn(String message, Object... arguments) { + if (arguments.length == 1 && OnapLoggingUtils.isThrowable(arguments[0])) { + log.warn(message, (Throwable)arguments[0]); + } else { + log.warn(OnapLoggingUtils.formatMessage(message, arguments)); + } + } + + /** + * Records a message. + * + * @param message the message */ @Override public void trace(Object message) { @@ -333,6 +394,21 @@ public class Logger4J implements org.onap.policy.common.logging.flexlogger.Logge /** * Records an audit message. * + * @param message the message + * @param arguments variable number of arguments + */ + @Override + public void audit(String message, Object... arguments) { + if (arguments.length == 1) { + log.info(message, (Throwable)arguments[0]); + } else { + log.info(OnapLoggingUtils.formatMessage(message, arguments)); + } + } + + /** + * Records an audit message. + * * @param eventId the event ID */ @Override @@ -444,6 +520,22 @@ public class Logger4J implements org.onap.policy.common.logging.flexlogger.Logge } /** + * Records a metrics message. + * + * @param message the message + * @param arguments variable number of arguments + */ + @Override + public void metrics(String message, Object... arguments) { + if (arguments.length > 0 && OnapLoggingUtils.isThrowable(arguments[arguments.length - 1])) { + log.info(OnapLoggingUtils.formatMessage(message, arguments), + (Throwable)arguments[arguments.length - 1]); + } else { + log.info(OnapLoggingUtils.formatMessage(message, arguments)); + } + } + + /** * Returns transaction Id. * * @param transId the transaction ID @@ -511,4 +603,5 @@ public class Logger4J implements org.onap.policy.common.logging.flexlogger.Logge // look up associated logger log = Logger.getLogger(className); } + } diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/SystemOutLogger.java b/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/SystemOutLogger.java index f7a68a3d..bc7633da 100644 --- a/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/SystemOutLogger.java +++ b/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/SystemOutLogger.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP-Logging * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,6 +28,7 @@ import java.io.Serializable; import java.util.Arrays; import java.util.UUID; +import org.onap.policy.common.logging.OnapLoggingUtils; import org.onap.policy.common.logging.eelf.MessageCodes; import org.onap.policy.common.logging.eelf.PolicyLogger; @@ -152,6 +153,21 @@ public class SystemOutLogger implements Logger, Serializable { } /** + * Records a message. + * + * @param message the message + * @param arguments variable number of arguments + */ + @Override + public void debug(String message, Object...arguments) { + if (arguments.length == 1 && OnapLoggingUtils.isThrowable(arguments[0])) { + displayMessage(transId + "|" + className + " : " + message + ":" + arguments[0]); + } else { + displayMessage(OnapLoggingUtils.formatMessage(message, arguments)); + } + } + + /** * Records an error message. * * @param message the message @@ -193,11 +209,25 @@ public class SystemOutLogger implements Logger, Serializable { */ @Override public void error(MessageCodes msg, String... arguments) { - displayMessage(transId + "|" + className + " : " + "MessageCode:" + msg + Arrays.asList(arguments)); } /** + * Records a error message. + * + * @param message the message + * @param arguments variable number of arguments + */ + @Override + public void error(String message, Object...arguments) { + if (arguments.length == 1 && OnapLoggingUtils.isThrowable(arguments[0])) { + displayMessage(transId + "|" + className + " : " + message + ":" + arguments[0]); + } else { + displayMessage(OnapLoggingUtils.formatMessage(message, arguments)); + } + } + + /** * Records a message. * * @param message the message @@ -222,21 +252,25 @@ public class SystemOutLogger implements Logger, Serializable { * Records a message. * * @param message the message + * @param arguments variable number of arguments */ @Override - public void warn(Object message) { - displayMessage(transId + "|" + className + " : " + message); + public void info(String message, Object...arguments) { + if (arguments.length == 1 && OnapLoggingUtils.isThrowable(arguments[0])) { + displayMessage(transId + "|" + className + " : " + message + ":" + arguments[0]); + } else { + displayMessage(OnapLoggingUtils.formatMessage(message, arguments)); + } } /** * Records a message. * * @param message the message - * @param throwable the throwable */ @Override - public void warn(Object message, Throwable throwable) { - displayMessage(transId + "|" + className + " : " + message + ":" + throwable); + public void warn(Object message) { + displayMessage(transId + "|" + className + " : " + message); } /** @@ -254,6 +288,17 @@ public class SystemOutLogger implements Logger, Serializable { /** * Records a message. * + * @param message the message + * @param throwable the throwable + */ + @Override + public void warn(Object message, Throwable throwable) { + displayMessage(transId + "|" + className + " : " + message + ":" + throwable); + } + + /** + * Records a message. + * * @param msg the message code * @param throwable the throwable * @param arguments the messages @@ -269,6 +314,21 @@ public class SystemOutLogger implements Logger, Serializable { * Records a message. * * @param message the message + * @param arguments variable number of arguments + */ + @Override + public void warn(String message, Object...arguments) { + if (arguments.length == 1 && OnapLoggingUtils.isThrowable(arguments[0])) { + displayMessage(transId + "|" + className + " : " + message + ":" + arguments[0]); + } else { + displayMessage(OnapLoggingUtils.formatMessage(message, arguments)); + } + } + + /** + * Records a message. + * + * @param message the message */ @Override public void trace(Object message) { @@ -373,6 +433,20 @@ public class SystemOutLogger implements Logger, Serializable { /** * Records an audit message. * + * @param message the message + */ + @Override + public void audit(String message, Object... arguments) { + if (arguments.length == 1) { + displayMessage(transId + "|" + className + " : " + message + ":" + arguments[0]); + } else { + displayMessage(OnapLoggingUtils.formatMessage(message, arguments)); + } + } + + /** + * Records an audit message. + * * @param eventId the event ID */ @Override @@ -480,6 +554,21 @@ public class SystemOutLogger implements Logger, Serializable { } /** + * Records a metrics message. + * + * @param message the message + * @param arguments the arguments + */ + @Override + public void metrics(String message, Object... arguments) { + if (arguments.length == 1) { + displayMessage(className + " : " + message + " : " + arguments[0]); + } else { + displayMessage(OnapLoggingUtils.formatMessage(message, arguments)); + } + } + + /** * Returns transaction Id. * * @param transId the transaction ID |