diff options
author | Joseph Chou <jc2555@att.com> | 2020-04-22 14:06:23 -0400 |
---|---|---|
committer | Joseph Chou <jc2555@att.com> | 2020-04-28 10:07:15 -0400 |
commit | 7968b32c3f18cf8e98d87229f100c622323cd78e (patch) | |
tree | 02fc7886f49adf12be047eb5bb5a15ab77c64b12 /common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/Logger4J.java | |
parent | 2cf13e0dcad627b8ba0b6b320c958b9026d1a975 (diff) |
Logging enhancement work
Update log tool to provide placeholder feature
Change-Id: I3f2b10d009a1d51f30a6080c07459eb0ac07189f
Issue-ID: POLICY-2478
Signed-off-by: Joseph Chou <jc2555@att.com>
Diffstat (limited to 'common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/Logger4J.java')
-rw-r--r-- | common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/Logger4J.java | 93 |
1 files changed, 93 insertions, 0 deletions
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); } + } |