diff options
author | 2018-07-29 16:13:45 +0300 | |
---|---|---|
committer | 2018-07-29 16:20:34 +0300 | |
commit | 5b593496b8f1b8e8be8d7d2dbcc223332e65a49b (patch) | |
tree | 2f9dfc45191e723da69cf74be7829784e9741b94 /common-app-api/src/main/java/org/openecomp/sdc/common/log/elements/LoggerFactory.java | |
parent | 9200382f2ce7b4bb729aa287d0878004b2d2b4f9 (diff) |
re base code
Change-Id: I12a5ca14a6d8a87e9316b9ff362eb131105f98a5
Issue-ID: SDC-1566
Signed-off-by: Michael Lando <ml636r@att.com>
Diffstat (limited to 'common-app-api/src/main/java/org/openecomp/sdc/common/log/elements/LoggerFactory.java')
-rw-r--r-- | common-app-api/src/main/java/org/openecomp/sdc/common/log/elements/LoggerFactory.java | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/log/elements/LoggerFactory.java b/common-app-api/src/main/java/org/openecomp/sdc/common/log/elements/LoggerFactory.java new file mode 100644 index 0000000000..de02c067c8 --- /dev/null +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/log/elements/LoggerFactory.java @@ -0,0 +1,58 @@ +package org.openecomp.sdc.common.log.elements; + +import org.slf4j.Logger; + +/** + * Created by dd4296 on 12/26/2017. + * this factory helps decouple the classes for Stopwatch and LogFieldsMdcHandler from + * the EcompLogger classes + */ +public class LoggerFactory { + + private LoggerFactory() { + } + + @SuppressWarnings("unchecked") + public static <T, V> V getLogger(Class<T> type, Logger logger) { + + if (type.getName().equals(LoggerAudit.class.getName())) { + return (V) new LoggerAudit(new LogFieldsMdcHandler(), logger); + } + + if (type.getName().equals(LoggerDebug.class.getName())) { + return (V) new LoggerDebug(new LogFieldsMdcHandler(), logger); + } + + if (type.getName().equals(LoggerMetric.class.getName())) { + return (V) new LoggerMetric(new LogFieldsMdcHandler(), logger); + } + + if (type.getName().equals(LoggerError.class.getName())) { + return (V) new LoggerError(new LogFieldsMdcHandler(), logger); + } + + return null; + } + + @SuppressWarnings("unchecked") + public static <T, V> V getMdcLogger(Class<T> type, Logger logger) { + + if (type.getName().equals(LoggerAudit.class.getName())) { + return (V) new LoggerAudit(LogFieldsMdcHandler.getInstance(), logger); + } + + if (type.getName().equals(LoggerDebug.class.getName())) { + return (V) new LoggerDebug(LogFieldsMdcHandler.getInstance(), logger); + } + + if (type.getName().equals(LoggerMetric.class.getName())) { + return (V) new LoggerMetric(LogFieldsMdcHandler.getInstance(), logger); + } + + if (type.getName().equals(LoggerError.class.getName())) { + return (V) new LoggerError(LogFieldsMdcHandler.getInstance(), logger); + } + + return null; + } +} |