2 * ============LICENSE_START=======================================================
3 * dcaegen2-collectors-veshv
4 * ================================================================================
5 * Copyright (C) 2018 NOKIA
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=========================================================
20 package org.onap.dcae.collectors.veshv.utils.logging
22 import org.slf4j.LoggerFactory
23 import kotlin.reflect.KClass
25 class Logger(val logger: org.slf4j.Logger) {
26 constructor(clazz: KClass<out Any>) : this(LoggerFactory.getLogger(clazz.java))
27 constructor(name: String) : this(LoggerFactory.getLogger(name))
33 val traceEnabled: Boolean
34 get() = logger.isTraceEnabled
36 fun trace(messageProvider: () -> String) {
37 if (logger.isTraceEnabled) {
38 logger.trace(messageProvider())
47 fun debug(message: String) {
51 fun debug(message: String, t: Throwable) {
52 logger.debug(message, t)
55 fun debug(messageProvider: () -> String) {
56 if (logger.isDebugEnabled) {
57 logger.debug(messageProvider())
61 fun debug(t: Throwable, messageProvider: () -> String) {
62 if (logger.isDebugEnabled) {
63 logger.debug(messageProvider(), t)
71 fun info(message: String) {
76 fun info(messageProvider: () -> String) {
77 if (logger.isInfoEnabled) {
78 logger.info(messageProvider())
82 fun info(message: String, t: Throwable) {
83 logger.info(message, t)
87 fun info(t: Throwable, messageProvider: () -> String) {
88 if (logger.isInfoEnabled) {
89 logger.info(messageProvider(), t)
98 fun warn(message: String) {
102 fun warn(message: String, t: Throwable) {
103 logger.warn(message, t)
106 fun warn(messageProvider: () -> String) {
107 if (logger.isWarnEnabled) {
108 logger.warn(messageProvider())
112 fun warn(t: Throwable, messageProvider: () -> String) {
113 if (logger.isWarnEnabled) {
114 logger.warn(messageProvider(), t)
123 fun error(message: String) {
124 logger.error(message)
128 fun error(message: String, t: Throwable) {
129 logger.error(message, t)
132 fun error(messageProvider: () -> String) {
133 if (logger.isErrorEnabled) {
134 logger.error(messageProvider())
138 fun error(t: Throwable, messageProvider: () -> String) {
139 if (logger.isErrorEnabled) {
140 logger.error(messageProvider(), t)