
br.com.objectos.way.base.log.Log Maven / Gradle / Ivy
The newest version!
/*
* Copyright 2014 Objectos, Fábrica de Software LTDA.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package br.com.objectos.way.base.log;
import java.lang.reflect.Method;
import org.joda.time.DateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author [email protected] (Marcio Endo)
*/
public class Log {
private final LogLevel level;
private final Class> type;
private final Method method;
private final String message;
private final DateTime dateTime;
Log(AbstractLogBuilder> builder) {
level = builder.getLevel();
type = builder.getType();
method = builder.getMethod();
dateTime = new DateTime();
message = builder.getMessage();
}
public LogLevel getLevel() {
return level;
}
public Class> getType() {
return type;
}
public String getClassName() {
String name = type.getName();
return WayLog.cleanClassName(name);
}
public Method getMethod() {
return method;
}
public String getMessage() {
return message;
}
public DateTime getDateTime() {
return dateTime;
}
public void log() {
String loggerName = getClassName();
Logger logger = LoggerFactory.getLogger(loggerName);
level.log(logger, message);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy