2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.core.logging;
23 import org.openecomp.core.logging.api.Logger;
24 import org.openecomp.core.logging.api.LoggerCreationService;
25 import org.slf4j.LoggerFactory;
27 public class Slf4JLoggerCreationService implements LoggerCreationService {
30 public Logger getLogger(String className) {
31 return new Slf4JWrapper(className);
35 public Logger getLogger(Class<?> clazz) {
36 return new Slf4JWrapper(clazz);
39 private class Slf4JWrapper implements Logger {
41 private final org.slf4j.Logger logger;
43 public Slf4JWrapper(Class<?> clazz) {
44 logger = LoggerFactory.getLogger(clazz);
47 public Slf4JWrapper(String className) {
48 logger = LoggerFactory.getLogger(className);
52 public String getName() {
53 return logger.getName();
57 public boolean isMetricsEnabled() {
58 return logger.isInfoEnabled(Markers.METRICS);
62 public void metrics(String msg) {
63 logger.info(Markers.METRICS, msg);
67 public void metrics(String msg, Object arg) {
68 logger.info(Markers.METRICS, msg, arg);
72 public void metrics(String msg, Object arg1, Object arg2) {
73 logger.info(Markers.METRICS, msg, arg1, arg2);
77 public void metrics(String msg, Object... arguments) {
78 logger.info(Markers.METRICS, msg, arguments);
82 public void metrics(String msg, Throwable throwable) {
83 logger.info(Markers.METRICS, msg, throwable);
87 public boolean isAuditEnabled() {
88 return logger.isInfoEnabled(Markers.AUDIT);
92 public void audit(String msg) {
93 logger.info(Markers.AUDIT, msg);
97 public void audit(String msg, Object arg) {
98 logger.info(Markers.AUDIT, msg, arg);
102 public void audit(String msg, Object arg1, Object arg2) {
103 logger.info(Markers.AUDIT, msg, arg1, arg2);
107 public void audit(String msg, Object... arguments) {
108 logger.info(Markers.AUDIT, msg, arguments);
112 public void audit(String msg, Throwable throwable) {
113 logger.info(Markers.AUDIT, msg, throwable);
117 public boolean isDebugEnabled() {
118 return logger.isDebugEnabled();
122 public void debug(String msg) {
127 public void debug(String format, Object arg) {
128 logger.debug(format, arg);
132 public void debug(String format, Object arg1, Object arg2) {
133 logger.debug(format, arg1, arg2);
137 public void debug(String format, Object... arguments) {
138 logger.debug(format, arguments);
142 public void debug(String msg, Throwable throwable) {
143 logger.debug(msg, throwable);
147 public boolean isInfoEnabled() {
148 return logger.isInfoEnabled();
152 public void info(String msg) {
157 public void info(String format, Object arg) {
158 logger.info(format, arg);
162 public void info(String format, Object arg1, Object arg2) {
163 logger.info(format, arg1, arg2);
167 public void info(String format, Object... arguments) {
168 logger.info(format, arguments);
172 public void info(String msg, Throwable throwable) {
173 logger.info(msg, throwable);
177 public boolean isWarnEnabled() {
178 return logger.isWarnEnabled();
182 public void warn(String msg) {
187 public void warn(String format, Object arg) {
188 logger.warn(format, arg);
192 public void warn(String format, Object... arguments) {
193 logger.warn(format, arguments);
197 public void warn(String format, Object arg1, Object arg2) {
198 logger.warn(format, arg1, arg2);
202 public void warn(String msg, Throwable throwable) {
203 logger.warn(msg, throwable);
207 public boolean isErrorEnabled() {
208 return logger.isErrorEnabled();
212 public void error(String msg) {
217 public void error(String format, Object arg) {
218 logger.error(format, arg);
222 public void error(String format, Object arg1, Object arg2) {
223 logger.error(format, arg1, arg2);
227 public void error(String format, Object... arguments) {
228 logger.error(format, arguments);
232 public void error(String msg, Throwable throwable) {
233 logger.error(msg, throwable);