public class SimpleLog
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
SimpleLog.Level
Enum containing all the LOG-levels
|
static interface |
SimpleLog.LogListener
This interface has to be able to register (via
addListener(net.dv8tion.jda.core.utils.SimpleLog.LogListener) ) and listen to log-messages. |
Modifier and Type | Field and Description |
---|---|
static boolean |
ENABLE_GUI
If this boolean is set to true, if there is no console present, messages are shown as message-dialogs
|
static SimpleLog.Level |
LEVEL
The global LOG-level that is used as standard if not overwritten
|
java.lang.String |
name |
Modifier and Type | Method and Description |
---|---|
static void |
addFileLog(SimpleLog.Level logLevel,
java.io.File file)
Sets up a File to log all messages that are not visible via sout and serr and meet a given log-level criteria.
|
static void |
addFileLogs(java.io.File std,
java.io.File err)
Will duplicate the output-streams to the specified Files.
|
static void |
addListener(SimpleLog.LogListener listener)
Adds a custom Listener that receives all logs
|
void |
debug(java.lang.Object msg)
Will LOG a message with debug level
|
void |
fatal(java.lang.Object msg)
Will LOG a message with fatal level
|
SimpleLog.Level |
getEffectiveLevel()
Gets the effective logging-level of this Logger.
|
SimpleLog.Level |
getLevel()
Gets the current logging-level of this Logger.
|
static SimpleLog |
getLog(java.lang.String name)
Will get the LOG with the given LOG-name or create one if it didn't exist
|
void |
info(java.lang.Object msg)
Will LOG a message with info level
|
static boolean |
isConsolePresent()
Will return whether the program has a console present, or was launched without
|
void |
log(SimpleLog.Level level,
java.lang.Object msg)
Will LOG a message with given LOG-level
|
void |
log(java.lang.Throwable ex) |
static void |
removeFileLog(java.io.File file)
Removes all File-logs created via
addFileLog(net.dv8tion.jda.core.utils.SimpleLog.Level, java.io.File) with given File. |
static void |
removeFileLog(SimpleLog.Level logLevel)
Removes all File-logs created via
addFileLog(net.dv8tion.jda.core.utils.SimpleLog.Level, java.io.File) with given Level. |
static void |
removeListener(SimpleLog.LogListener listener)
Removes a custom Listener
|
void |
setLevel(SimpleLog.Level lev)
Set the LOG-level
All messages with lower LOG-level will not be printed
If this level is set to null, the global Log-level (
LEVEL ) will be used |
void |
trace(java.lang.Object msg)
Will LOG a message with trace level.
|
void |
warn(java.lang.Object msg)
Will LOG a message with warning level
|
public static SimpleLog.Level LEVEL
public static boolean ENABLE_GUI
public final java.lang.String name
public static SimpleLog getLog(java.lang.String name)
name
- the name of the LOGpublic static void addFileLogs(java.io.File std, java.io.File err) throws java.io.IOException
std
- The file to use for System.out logging, or null to not LOG System.out to a fileerr
- The file to use for System.err logging, or null to not LOG System.err to a filejava.io.IOException
- If an IO error is encountered while dealing with the file. Most likely
to be caused by a lack of permissions when creating the log folders or files.public static void addFileLog(SimpleLog.Level logLevel, java.io.File file) throws java.io.IOException
addFileLogs(java.io.File, java.io.File)
instead.logLevel
- The log-level criteria. Only logs equal or above this level are printed to the Filefile
- The File where the logs should be printedjava.io.IOException
- If the File can't be canonically resolved (access denied)public static void removeFileLog(SimpleLog.Level logLevel)
addFileLog(net.dv8tion.jda.core.utils.SimpleLog.Level, java.io.File)
with given Level.
To remove the sout and serr logs, call addFileLogs(java.io.File, java.io.File)
with null args.logLevel
- The level for which all fileLogs should be removedpublic static void removeFileLog(java.io.File file) throws java.io.IOException
addFileLog(net.dv8tion.jda.core.utils.SimpleLog.Level, java.io.File)
with given File.
To remove the sout and serr logs, call addFileLogs(java.io.File, java.io.File)
with null args.file
- The file to remove from all FileLogs (except sout and serr logs)java.io.IOException
- If the File can't be canonically resolved (access denied)public static void addListener(SimpleLog.LogListener listener)
listener
- the listener to addpublic static void removeListener(SimpleLog.LogListener listener)
listener
- the listener to removepublic void setLevel(SimpleLog.Level lev)
LEVEL
) will be usedlev
- the new LOG-levelpublic SimpleLog.Level getLevel()
public SimpleLog.Level getEffectiveLevel()
public void log(SimpleLog.Level level, java.lang.Object msg)
level
- The level of the Logmsg
- The message to LOGpublic void log(java.lang.Throwable ex)
public void trace(java.lang.Object msg)
msg
- the object, which should be loggedpublic void debug(java.lang.Object msg)
msg
- the object, which should be loggedpublic void info(java.lang.Object msg)
msg
- the object, which should be loggedpublic void warn(java.lang.Object msg)
msg
- the object, which should be loggedpublic void fatal(java.lang.Object msg)
msg
- the object, which should be loggedpublic static boolean isConsolePresent()