Package io.fi0x.javalogger.logging
Class Logger
java.lang.Object
io.fi0x.javalogger.logging.Logger
This class can be used for logging to the default output
and to a log-file.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic booleancreateNewTemplate(Enum<?> templateName, String colorCode, String logLevel) static booleancreateNewTemplate(Enum<?> templateName, String colorCode, String logLevel, boolean writeToFile) static booleancreateNewTemplate(Enum<?> templateName, String colorCode, String logLevel, boolean writeToFile, boolean onlyVerbose, boolean onlyDebug) static booleancreateNewTemplate(Enum<?> templateName, String colorCode, String logLevel, boolean writeToFile, boolean onlyVerbose, boolean onlyDebug, boolean hidePrefix) static booleancreateNewTemplate(Enum<?> templateName, String colorCode, String logLevel, boolean writeToFile, boolean onlyVerbose, boolean onlyDebug, boolean hidePrefix, boolean mixpanelMessage) static booleancreateNewTemplate(Enum<?> templateName, String colorCode, String logLevel, boolean writeToFile, boolean onlyVerbose, boolean onlyDebug, boolean hidePrefix, boolean mixpanelMessage, String mixpanelName) static booleancreateNewTemplate(Enum<?> templateName, String colorCode, String backgroundColorCode, String logLevel, boolean writeToFile, boolean onlyVerbose, boolean onlyDebug, boolean hidePrefix, boolean exceptionsInConsole, boolean mixpanelMessage, String mixpanelName) static booleancreateNewTemplate(Enum<?> templateName, String colorCode, String backgroundColorCode, String logLevel, boolean writeToFile, boolean onlyVerbose, boolean onlyDebug, boolean hidePrefix, boolean mixpanelMessage, String mixpanelName) static booleancreateNewTemplate(String templateName, String colorCode, String logLevel) static booleancreateNewTemplate(String templateName, String colorCode, String logLevel, boolean writeToFile) static booleancreateNewTemplate(String templateName, String colorCode, String logLevel, boolean writeToFile, boolean onlyVerbose, boolean onlyDebug) static booleancreateNewTemplate(String templateName, String colorCode, String logLevel, boolean writeToFile, boolean onlyVerbose, boolean onlyDebug, boolean hidePrefix) static booleancreateNewTemplate(String templateName, String colorCode, String logLevel, boolean writeToFile, boolean onlyVerbose, boolean onlyDebug, boolean hidePrefix, boolean mixpanelMessage) static booleancreateNewTemplate(String templateName, String colorCode, String logLevel, boolean writeToFile, boolean onlyVerbose, boolean onlyDebug, boolean hidePrefix, boolean mixpanelMessage, String mixpanelName) static booleancreateNewTemplate(String templateName, String colorCode, String backgroundColorCode, String logLevel, boolean writeToFile, boolean onlyVerbose, boolean onlyDebug, boolean hidePrefix, boolean exceptionsInConsole, boolean mixpanelMessage, String mixpanelName) Create a newLogTemplatefor logging that can be used to quickly create a newLogEntry.static booleancreateNewTemplate(String templateName, String colorCode, String backgroundColorCode, String logLevel, boolean writeToFile, boolean onlyVerbose, boolean onlyDebug, boolean hidePrefix, boolean mixpanelMessage, String mixpanelName) static LoggerGet theLogger-singleton and create it if it does not exist yet.static voidstatic booleanstatic booleanstatic booleanstatic booleanstatic booleanstatic booleanCreate aLogEntrywith the specified text andLogTemplate.voidsetConsoleExceptions(boolean showExceptionsInConsole) Change the way Exceptions are displayed in the console.voidsetDebug(boolean isDebugMode) Change the current debug-mode.voidsetLogFolder(File logFolder) Change the folder where log-files should be stored.voidsetSmallLog(boolean ignorePrefixes) Change the wayLogEntrys are displayed.voidsetVerbose(boolean isVerboseMode) Change the current verbose-mode.
-
Method Details
-
getInstance
Get theLogger-singleton and create it if it does not exist yet.- Returns:
- The instance of the
Logger-singleton.
-
setLogFolder
Change the folder where log-files should be stored. If a log-file already exists in the current log-folder, it will be ignored for any future logging and the new log-folder location will be used instead.- Parameters:
logFolder- The path where future log-files should be stored (Default is "PROGRAMDATA/JavaLogger").
-
setDebug
public void setDebug(boolean isDebugMode) Change the current debug-mode.LogEntrys whose 'DEBUG' method was set, are only visible if this method is set to true.- Parameters:
isDebugMode- Weather or not theLoggershould work in debug-mode (Default is false).
-
setVerbose
public void setVerbose(boolean isVerboseMode) Change the current verbose-mode.LogEntrys whose 'VERBOSE' method was set, are only visible if this method is set to true.- Parameters:
isVerboseMode- Weather or not theLoggershould work in verbose-mode (Default is false).
-
setSmallLog
public void setSmallLog(boolean ignorePrefixes) Change the wayLogEntrys are displayed. Using small-logs will remove all prefixes from logging. This has the same effect as the plaintext setting in a singleLogEntry, but will affect all logging.- Parameters:
ignorePrefixes- Weather or not theLoggershould use small-logs (Default is false).
-
setConsoleExceptions
public void setConsoleExceptions(boolean showExceptionsInConsole) Change the way Exceptions are displayed in the console. Using console-exceptions will print out all StackTraces of exceptions in your console. This has the same effect as the consoleException setting in a singleLogEntry, but will affect all logging.- Parameters:
showExceptionsInConsole- Weather or not theLoggershould print StackTraces in the console (Default is false).
-
log
Print theLogEntryprovided with the settings that are stored in theLogEntry. If theLogEntryis set to VERBOSE or DEBUG, it will only be processed if theLoggerhas activated that mode.- Parameters:
log- TheLogEntrythat should be processed.
-
log
Create aLogEntrywith the specified text andLogTemplate.- Parameters:
text- The message to log.templateName- The name of theLogTemplatethat should be used.e- The exception that should get logged (Default is null).errorCode- The code for the error that occured (Default is 0).- Returns:
- True if logging was successful, False if the
LogTemplatedoes not exist.
-
log
- See Also:
-
log
- See Also:
-
log
- See Also:
-
log
- See Also:
-
log
- See Also:
-
createNewTemplate
public static boolean createNewTemplate(String templateName, String colorCode, String backgroundColorCode, String logLevel, boolean writeToFile, boolean onlyVerbose, boolean onlyDebug, boolean hidePrefix, boolean exceptionsInConsole, boolean mixpanelMessage, String mixpanelName) Create a newLogTemplatefor logging that can be used to quickly create a newLogEntry.- Parameters:
templateName- The name which is required to find theLogTemplateagain.colorCode- The color which will be used in the console output.backgroundColorCode- The background color which will be used in the console output.logLevel- The logging-level.writeToFile- IfLogEntrys written with thisLogTemplateshould be saved in a log-file.onlyVerbose- IfLogEntrys with these settings should only be visible in verbose-mode.onlyDebug- IfLogEntrys with these settings should only be visible in debug-mode.hidePrefix- If only the actual message without timestamp, logging-level and error-code should be shown.exceptionsInConsole- IfLogEntrys whith these settings should print their exceptions in the console.mixpanelMessage- If theLogEntryshould be sent to Mixpanel.mixpanelName- The name of the Mixpanel-event.- Returns:
- True if the
LogTemplatewas created successfully, False if theLogTemplatewas overwritten.
-
createNewTemplate
-
createNewTemplate
-
createNewTemplate
-
createNewTemplate
-
createNewTemplate
-
createNewTemplate
-
createNewTemplate
-
createNewTemplate
-
createNewTemplate
-
createNewTemplate
-
createNewTemplate
-
createNewTemplate
-
createNewTemplate
-
createNewTemplate
-
createNewTemplate
-