Standalone TCA with EELF Logger
[dcaegen2/analytics/tca-gen2.git] / eelf-logger / eelf-logger-logback-impl / src / main / java / org / onap / dcae / utils / eelf / logger / logback / log / EELFLoggerImpl.java
1 /*
2  * ================================================================================
3  * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
4  * ================================================================================
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  * ============LICENSE_END=========================================================
17  *
18  */
19
20 package org.onap.dcae.utils.eelf.logger.logback.log;
21
22
23 import org.onap.dcae.utils.eelf.logger.api.log.AuditLog;
24 import org.onap.dcae.utils.eelf.logger.api.log.DebugLog;
25 import org.onap.dcae.utils.eelf.logger.api.log.EELFLogger;
26 import org.onap.dcae.utils.eelf.logger.api.log.EELFLoggerContext;
27 import org.onap.dcae.utils.eelf.logger.api.log.ErrorLog;
28 import org.onap.dcae.utils.eelf.logger.api.log.MetricLog;
29 import org.slf4j.Logger;
30 import org.slf4j.LoggerFactory;
31
32 /**
33  * EELF Logger Logback Implementation
34  *
35  * @author Rajiv Singla
36  */
37 public class EELFLoggerImpl implements EELFLogger {
38
39     private Logger logger;
40     private Class<?> clazz;
41
42     public EELFLoggerImpl() {
43         // no arg constructor required for Service Loader discovery
44     }
45
46     public EELFLoggerImpl(final Class<?> clazz) {
47         logger = LoggerFactory.getLogger(clazz);
48         this.clazz = clazz;
49     }
50
51
52     @Override
53     public AuditLog auditLog() {
54         return new AuditLogImpl(logger, clazz);
55     }
56
57     @Override
58     public MetricLog metricLog() {
59         return new MetricLogImpl(logger, clazz);
60     }
61
62     @Override
63     public ErrorLog errorLog() {
64         return new ErrorLogImpl(logger, clazz);
65     }
66
67     @Override
68     public DebugLog debugLog() {
69         return new DebugLogImpl(logger, clazz);
70     }
71
72     @Override
73     public EELFLoggerContext loggingContext() {
74         return new EELFLoggerContextImpl();
75     }
76
77     @Override
78     public String toString() {
79         return "EELF LOGBACK IMP";
80     }
81 }