Package com.chrisnewland.freelogj
Class Logger
- java.lang.Object
-
- com.chrisnewland.freelogj.Logger
-
public class Logger extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classLogger.LogLevel
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringBRACESprivate java.lang.StringclassNameprivate java.time.format.DateTimeFormatterdateFormat(package private) static java.time.format.DateTimeFormatterDEFAULT_DATE_FORMATprivate Logger.LogLevellogLevelprivate java.io.PrintStreamprintStream
-
Constructor Summary
Constructors Modifier Constructor Description privateLogger(java.lang.Class<?> clazz, Logger.LogLevel logLevel, java.time.format.DateTimeFormatter dateFormat, java.io.PrintStream printStream)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddebug(java.lang.String message, java.lang.Object... args)Output a message at the DEBUGLogger.LogLevel.voiderror(java.lang.String message, java.lang.Object... args)Output a message at the ERRORLogger.LogLevel.voidfatal(java.lang.String message, java.lang.Object... args)Output a message at the FATALLogger.LogLevel.static LoggergetLogger(java.lang.Class<?> clazz)Returns a Logger for the given Class.static LoggergetLogger(java.lang.Class<?> clazz, Logger.LogLevel logLevel)Returns a Logger for the given Class and LogLevel.static LoggergetLogger(java.lang.Class<?> clazz, Logger.LogLevel logLevel, java.io.PrintStream printStream)Returns a Logger for the given Class and LogLevel andPrintStream.static LoggergetLogger(java.lang.Class<?> clazz, Logger.LogLevel logLevel, java.time.format.DateTimeFormatter dateFormat, java.io.PrintStream printStream)Returns a Logger for the given Class, LogLevel,DateTimeFormatter, andPrintStream.voidinfo(java.lang.String message, java.lang.Object... args)Output a message at the INFOLogger.LogLevel.booleanisDebugEnabled()booleanisErrorEnabled()booleanisFatalEnabled()booleanisInfoEnabled()booleanisTraceEnabled()booleanisWarnEnabled()private voidlog(Logger.LogLevel logLevel, java.lang.String message, java.lang.Object... args)voidtrace(java.lang.String message, java.lang.Object... args)Output a message at the TRACELogger.LogLevel.voidwarn(java.lang.String message, java.lang.Object... args)Output a message at the WARNLogger.LogLevel.
-
-
-
Field Detail
-
DEFAULT_DATE_FORMAT
static final java.time.format.DateTimeFormatter DEFAULT_DATE_FORMAT
-
BRACES
private static final java.lang.String BRACES
- See Also:
- Constant Field Values
-
className
private final java.lang.String className
-
logLevel
private final Logger.LogLevel logLevel
-
dateFormat
private final java.time.format.DateTimeFormatter dateFormat
-
printStream
private final java.io.PrintStream printStream
-
-
Constructor Detail
-
Logger
private Logger(java.lang.Class<?> clazz, Logger.LogLevel logLevel, java.time.format.DateTimeFormatter dateFormat, java.io.PrintStream printStream)
-
-
Method Detail
-
getLogger
public static Logger getLogger(java.lang.Class<?> clazz)
Returns a Logger for the given Class. The fully qualified class name is printed on each log line.- Parameters:
clazz- The class to be logged
-
getLogger
public static Logger getLogger(java.lang.Class<?> clazz, Logger.LogLevel logLevel)
Returns a Logger for the given Class and LogLevel. The fully qualified class name is printed on each log line.- Parameters:
clazz- The class to be logged
-
getLogger
public static Logger getLogger(java.lang.Class<?> clazz, Logger.LogLevel logLevel, java.io.PrintStream printStream)
Returns a Logger for the given Class and LogLevel andPrintStream. The fully qualified class name is printed on each log line.- Parameters:
clazz- The class to be logged
-
getLogger
public static Logger getLogger(java.lang.Class<?> clazz, Logger.LogLevel logLevel, java.time.format.DateTimeFormatter dateFormat, java.io.PrintStream printStream)
Returns a Logger for the given Class, LogLevel,DateTimeFormatter, andPrintStream. The fully qualified class name is printed on each log line.- Parameters:
clazz- The class to be logged
-
isTraceEnabled
public boolean isTraceEnabled()
- Returns:
- true if the TRACE
Logger.LogLevelis enabled.
-
isDebugEnabled
public boolean isDebugEnabled()
- Returns:
- true if the DEBUG
Logger.LogLevelis enabled.
-
isInfoEnabled
public boolean isInfoEnabled()
- Returns:
- true if the INFO
Logger.LogLevelis enabled.
-
isWarnEnabled
public boolean isWarnEnabled()
- Returns:
- true if the WARN
Logger.LogLevelis enabled.
-
isErrorEnabled
public boolean isErrorEnabled()
- Returns:
- true if the ERROR
Logger.LogLevelis enabled.
-
isFatalEnabled
public boolean isFatalEnabled()
- Returns:
- true if the FATAL
Logger.LogLevelis enabled.
-
trace
public void trace(java.lang.String message, java.lang.Object... args)Output a message at the TRACELogger.LogLevel.- Parameters:
message- The message to output.args- Arguments to be substituted for {} in the message String.
-
debug
public void debug(java.lang.String message, java.lang.Object... args)Output a message at the DEBUGLogger.LogLevel.- Parameters:
message- The message to output.args- Arguments to be substituted for {} in the message String.
-
info
public void info(java.lang.String message, java.lang.Object... args)Output a message at the INFOLogger.LogLevel.- Parameters:
message- The message to output.args- Arguments to be substituted for {} in the message String.
-
warn
public void warn(java.lang.String message, java.lang.Object... args)Output a message at the WARNLogger.LogLevel.- Parameters:
message- The message to output.args- Arguments to be substituted for {} in the message String.
-
error
public void error(java.lang.String message, java.lang.Object... args)Output a message at the ERRORLogger.LogLevel.- Parameters:
message- The message to output.args- Arguments to be substituted for {} in the message String.
-
fatal
public void fatal(java.lang.String message, java.lang.Object... args)Output a message at the FATALLogger.LogLevel.- Parameters:
message- The message to output.args- Arguments to be substituted for {} in the message String.
-
log
private void log(Logger.LogLevel logLevel, java.lang.String message, java.lang.Object... args)
-
-