org.beigesoft.alog.LoggerSimple Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of a-jetty-base Show documentation
Show all versions of a-jetty-base Show documentation
A-Jetty Base can run on Android Java as well as on standard Java 7+ and it can run precompiled JSP/JSTL.
package org.beigesoft.alog;
/*
* Beigesoft ™
*
* Licensed under the Apache License, Version 2.0
*
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*/
import java.util.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
/**
* Simple logger to console.
*
* @author Yury Demidenko
*/
public class LoggerSimple implements ILogger {
/**
* Is show debug messages.
**/
private boolean isShowDebugMessage;
/**
* Date formatter.
**/
private DateFormat dateFormat =
new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
/**
* Make debug log.
* @param pClazz of debudgged bean
* @param pMsg message
**/
@Override
public final void debug(final Class> pClazz,
final String pMsg) {
if (this.isShowDebugMessage) {
System.out.println(dateFormat.format(new Date()) + " DEBUG "
+ pClazz.getSimpleName() + " - " + pMsg);
}
}
/**
* Make info log.
* @param pClazz of bean
* @param pMsg message
**/
@Override
public final void info(final Class> pClazz,
final String pMsg) {
System.out.println(dateFormat.format(new Date()) + " INFO "
+ pClazz.getSimpleName() + " - " + pMsg);
}
/**
* Make error log.
* @param pClazz of bean
* @param pMsg message
**/
@Override
public final void error(final Class> pClazz,
final String pMsg) {
System.err.println(dateFormat.format(new Date()) + " ERROR "
+ pClazz.getSimpleName() + " - " + pMsg);
}
/**
* Make warn log.
* @param pClazz of bean
* @param pMsg message
**/
@Override
public final void warn(final Class> pClazz,
final String pMsg) {
System.out.println(dateFormat.format(new Date()) + " WARN "
+ pClazz.getSimpleName() + " - " + pMsg);
}
/**
* Set is show debug messages.
* @param pIsShowDebugMessage is show debug messages?
**/
@Override
public final void setIsShowDebugMessages(
final boolean pIsShowDebugMessage) {
this.isShowDebugMessage = pIsShowDebugMessage;
}
/**
* Get is show debug messages.
* @return is show debug messages?
**/
@Override
public final boolean getIsShowDebugMessages() {
return this.isShowDebugMessage;
}
}