public class Logger
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
Logger.Level |
Constructor and Description |
---|
Logger()
Creates a new console logger with default importance level OUTPUT
|
Logger(java.io.File file,
boolean append)
Creates a new logger with default importance level OUTPUT
|
Logger(java.io.File file,
boolean append,
Logger.Level level)
Creates a new logger
|
Logger(java.io.File file,
boolean append,
Logger.Level level,
boolean only)
Creates a new logger
|
Logger(Logger.Level level)
Creates a new console logger
|
Logger(Logger.Level level,
boolean only)
Creates a new console logger
|
Logger(java.lang.String filePath,
boolean append)
Creates a new logger with default importance level OUTPUT
|
Logger(java.lang.String filePath,
boolean append,
Logger.Level level)
Creates a new logger
|
Logger(java.lang.String filePath,
boolean append,
Logger.Level level,
boolean only)
Creates a new logger
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the log file
|
static void |
closeDefaultLogger()
Closes the default log file.
|
static void |
defaultError(java.lang.Exception exception)
Writes an error-level exception to the default log
|
static void |
defaultError(java.lang.String content)
Writes an error-level message to the default log
|
static void |
defaultFatal(java.lang.Exception exception)
Writes a fatal-level exception to the default log
|
static void |
defaultFatal(java.lang.String content)
Writes a fatal-level message to the default log
|
static void |
defaultLog(java.lang.Exception exception,
Logger.Level level)
Writes the exception to the default log file at the given importance
level
|
static void |
defaultLog(java.lang.String content,
Logger.Level level)
Writes the content to the default log file at the given importance level
|
static void |
defaultOutput(java.lang.Exception exception)
Writes an output-level exception to the default log
|
static void |
defaultOutput(java.lang.String content)
Writes an output-level message to the default log
|
static void |
defaultVerbose(java.lang.Exception exception)
Writes a verbose-level exception to the default log
|
static void |
defaultVerbose(java.lang.String content)
Writes a verbose-level message to the default log
|
static void |
defaultWarn(java.lang.Exception exception)
Writes a warn-level exception to the default log
|
static void |
defaultWarn(java.lang.String content)
Writes a warn-level message to the default log
|
void |
error(java.lang.Exception exception)
Writes an error-level exception to the log
|
void |
error(java.lang.String content)
Writes an error-level message to the log
|
void |
fatal(java.lang.Exception exception)
Writes a fatal-level exception to the log
|
void |
fatal(java.lang.String content)
Writes a fatal-level message to the log
|
void |
log(java.lang.Exception exception,
Logger.Level level)
Writes the exception to the log file at the given importance level
|
void |
log(java.lang.String content,
Logger.Level level)
Writes the content to the log file at the given importance level
|
static Logger |
nullLogger()
Returns the null logger which doesn't log anything
|
void |
output(java.lang.Exception exception)
Writes an output-level exception to the log
|
void |
output(java.lang.String content)
Writes an output-level message to the log
|
static void |
setDefaultLevel(Logger.Level level,
boolean only)
Sets the logger level for the default logger.
|
void |
setLevel(Logger.Level level,
boolean only)
Sets the logger level.
|
void |
verbose(java.lang.Exception exception)
Writes a verbose-level exception to the log
|
void |
verbose(java.lang.String content)
Writes a verbose-level message to the log
|
void |
warn(java.lang.Exception exception)
Writes a warn-level exception to the log
|
void |
warn(java.lang.String content)
Writes a warn-level message to the log
|
public Logger() throws java.io.IOException
java.io.IOException
- if an error occurs initializing the loggerpublic Logger(java.io.File file, boolean append) throws java.io.IOException
file
- the file to log toappend
- whether to append to the filejava.io.IOException
- if the file can't be openedpublic Logger(java.io.File file, boolean append, Logger.Level level) throws java.io.IOException
file
- the file to log toappend
- whether to append to the filelevel
- the minimum importance level to show logs fromjava.io.IOException
- if the file can't be openedpublic Logger(java.io.File file, boolean append, Logger.Level level, boolean only) throws java.io.IOException
file
- the file to log toappend
- whether to append to the filelevel
- the minimum importance level to show logs fromonly
- whether to show ONLY the logs at the given level or also those
above that leveljava.io.IOException
- if the file can't be openedpublic Logger(Logger.Level level) throws java.io.IOException
level
- the minimum importance level to show logs fromjava.io.IOException
- if an error occurs initializing the loggerpublic Logger(Logger.Level level, boolean only) throws java.io.IOException
level
- the minimum importance level to show logs fromonly
- whether to show ONLY the logs at the given level or also those
above that leveljava.io.IOException
- if an error occurs initializing the loggerpublic Logger(java.lang.String filePath, boolean append) throws java.io.IOException
filePath
- the file to log toappend
- whether to append to the filejava.io.IOException
- if the file can't be openedpublic Logger(java.lang.String filePath, boolean append, Logger.Level level) throws java.io.IOException
filePath
- the file to log toappend
- whether to append to the filelevel
- the minimum importance level to show logs fromjava.io.IOException
- if the file can't be openedpublic Logger(java.lang.String filePath, boolean append, Logger.Level level, boolean only) throws java.io.IOException
filePath
- the file to log toappend
- whether to append to the filelevel
- the minimum importance level to show logs fromonly
- whether to show ONLY the logs at the given level or also those
above that leveljava.io.IOException
- if the file can't be openedpublic static void closeDefaultLogger()
public static void defaultError(java.lang.Exception exception)
exception
- the exception to logpublic static void defaultError(java.lang.String content)
content
- the message to logpublic static void defaultFatal(java.lang.Exception exception)
exception
- the exception to logpublic static void defaultFatal(java.lang.String content)
content
- the message to logpublic static void defaultLog(java.lang.Exception exception, Logger.Level level)
exception
- the exception to loglevel
- the importance level of the messagepublic static void defaultLog(java.lang.String content, Logger.Level level)
content
- the message to loglevel
- the importance level of the messagepublic static void defaultOutput(java.lang.Exception exception)
exception
- the exception to logpublic static void defaultOutput(java.lang.String content)
content
- the message to logpublic static void defaultVerbose(java.lang.Exception exception)
exception
- the exception to logpublic static void defaultVerbose(java.lang.String content)
content
- the message to logpublic static void defaultWarn(java.lang.Exception exception)
exception
- the exception to logpublic static void defaultWarn(java.lang.String content)
content
- the message to logpublic static Logger nullLogger()
public static void setDefaultLevel(Logger.Level level, boolean only)
level
- the level to setonly
- determines whether to only show logs at this level, or to also
show logs of higher importancepublic void close()
public void error(java.lang.Exception exception)
exception
- the exception to logpublic void error(java.lang.String content)
content
- the message to logpublic void fatal(java.lang.Exception exception)
exception
- the exception to logpublic void fatal(java.lang.String content)
content
- the message to logpublic void log(java.lang.Exception exception, Logger.Level level)
exception
- the exception to loglevel
- the importance level of the messagepublic void log(java.lang.String content, Logger.Level level)
content
- the message to loglevel
- the importance level of the messagepublic void output(java.lang.Exception exception)
exception
- the exception to logpublic void output(java.lang.String content)
content
- the message to logpublic void setLevel(Logger.Level level, boolean only)
level
- the level to setonly
- determines whether to only show logs at this level, or to also
show logs of higher importancepublic void verbose(java.lang.Exception exception)
exception
- the exception to logpublic void verbose(java.lang.String content)
content
- the message to logpublic void warn(java.lang.Exception exception)
exception
- the exception to logpublic void warn(java.lang.String content)
content
- the message to log