![JAR search and dependency download from the Maven repository](/logo.png)
tools.dynamia.commons.logger.SLF4JLoggingService Maven / Gradle / Ivy
/*
* Copyright (C) 2009 - 2019 Dynamia Soluciones IT S.A.S - NIT 900302344-1
* Colombia - South America
* All Rights Reserved.
*
* DynamiaTools is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License (LGPL v3) as
* published by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* DynamiaTools is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with DynamiaTools. If not, see .
*/
package tools.dynamia.commons.logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.Serializable;
/**
* The Class SLF4JLoggingService.
*
* @author Mario A. Serrano Leones
*/
public class SLF4JLoggingService implements LoggingService, Serializable {
/**
*
*/
private static final long serialVersionUID = -4196725472501595832L;
/**
* The logger.
*/
private Logger logger = null;
private String prefix = "";
/**
* Instantiates a new SL f4 j logging service.
*/
public SLF4JLoggingService() {
logger = LoggerFactory.getLogger(LoggingService.class);
}
/**
* Instantiates a new SL f4 j logging service.
*
* @param clazz the clazz
*/
public SLF4JLoggingService(Class> clazz) {
logger = LoggerFactory.getLogger(clazz);
}
public SLF4JLoggingService(Class> clazz, String prefix) {
this(clazz);
if (prefix == null) {
prefix = "";
}
this.prefix = prefix;
}
/*
* (non-Javadoc)
*
* @see tools.dynamia.commons.logger.LoggingService#debug(java.lang.String)
*/
@Override
public void debug(String message) {
if (isDebugEnabled()) {
logger.debug(prefix + message);
}
}
/*
* (non-Javadoc)
*
* @see tools.dynamia.commons.logger.LoggingService#info(java.lang.String)
*/
@Override
public void info(String message) {
logger.info(prefix + message);
}
/*
* (non-Javadoc)
*
* @see tools.dynamia.commons.logger.LoggingService#warn(java.lang.String)
*/
@Override
public void warn(String message) {
logger.warn(prefix + message);
}
/*
* (non-Javadoc)
*
* @see tools.dynamia.commons.logger.LoggingService#error(java.lang.String)
*/
@Override
public void error(String message) {
logger.error(prefix + message);
}
/*
* (non-Javadoc)
*
* @see tools.dynamia.commons.logger.LoggingService#error(java.lang.String,
* java.lang.Throwable)
*/
@Override
public void error(String message, Throwable t) {
logger.error(prefix + message, t);
}
/*
* (non-Javadoc)
*
* @see
* tools.dynamia.commons.logger.LoggingService#error(java.lang.Throwable)
*/
@Override
public void error(Throwable t) {
logger.error(prefix + t.getMessage(), t);
}
/*
* (non-Javadoc)
*
* @see tools.dynamia.commons.logger.LoggingService#isDebugEnabled()
*/
@Override
public boolean isDebugEnabled() {
return logger.isDebugEnabled();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy