Package ml.karmaconfigs.api.common.utils
Class KarmaLogger
java.lang.Object
ml.karmaconfigs.api.common.utils.KarmaLogger
- All Implemented Interfaces:
AutoCloseable
- Direct Known Subclasses:
BufferedLogger,Logger
Karma logger
-
Constructor Summary
ConstructorsConstructorDescriptionKarmaLogger(KarmaSource owner)Initialize the karma loggerKarmaLogger(KarmaSource owner, boolean autoFlush, boolean errors, boolean messages)Initialize the karma logger -
Method Summary
Modifier and TypeMethodDescriptionabstract voidclearLog()Clear the log filevoidclose()This means remove the logger name attachment so you can create a new logger instance with new logger optionsprotected StringfetchTime(LogCalendar type)Get the now's timeabstract booleanflush()Flush the log data if the log auto flush is turned off WARNING: This will replace all the log file content, this should be used only for applications that runs once -> generate a log file and then switch log file.static @Nullable KarmaLoggerGet the requested logger or KarmaAPI's logger if there's not any logger with the provided nameprotected PathgetLoggerFile(LogExtension type)Get the today's logger fileprotected booleanGet if the logger prints errorsprotected booleanGet if the logger prints infoabstract voidscheduleLog(Level level, CharSequence info, Object... replaces)Run the log function on a new threadabstract voidscheduleLog(Level level, Throwable error)Run the log function on a new threadabstract voidscheduleLogOption(Level level, boolean print, CharSequence info, Object... replaces)Run the log function on a new threadabstract voidscheduleLogOption(Level level, boolean print, Throwable error)Run the log function on a new threadabstract voidsyncedLog(Level level, CharSequence info, Object... replaces)Run the log function on the main known threadabstract voidRun the log function on the main known threadabstract voidsyncedLogOption(Level level, boolean print, CharSequence info, Object... replaces)Run the log function on the main known threadabstract voidsyncedLogOption(Level level, boolean print, Throwable error)Run the log function on the main known thread
-
Constructor Details
-
KarmaLogger
Initialize the karma logger- Parameters:
owner- the logger owner
-
KarmaLogger
Initialize the karma logger- Parameters:
owner- the logger ownerautoFlush- auto flush log fileserrors- display errors as messages toomessages- display messages as console messages too
-
-
Method Details
-
scheduleLog
Run the log function on a new thread- Parameters:
level- the log levelinfo- the info to logreplaces- the info replaces
-
scheduleLog
Run the log function on a new thread- Parameters:
level- the log levelerror- the error to log
-
scheduleLogOption
public abstract void scheduleLogOption(Level level, boolean print, CharSequence info, Object... replaces)Run the log function on a new thread- Parameters:
level- the log levelprint- print info to consoleinfo- the info to logreplaces- the info replaces
-
scheduleLogOption
Run the log function on a new thread- Parameters:
level- the log levelprint- print info to consoleerror- the error to log
-
syncedLog
Run the log function on the main known thread- Parameters:
level- the log levelinfo- the info to logreplaces- the info replaces
-
syncedLog
Run the log function on the main known thread- Parameters:
level- the log levelerror- the error to log
-
syncedLogOption
public abstract void syncedLogOption(Level level, boolean print, CharSequence info, Object... replaces)Run the log function on the main known thread- Parameters:
level- the log levelprint- print info to consoleinfo- the info to logreplaces- the info replaces
-
syncedLogOption
Run the log function on the main known thread- Parameters:
level- the log levelprint- print info to consoleerror- the error to log
-
clearLog
public abstract void clearLog()Clear the log file -
flush
@Experimental public abstract boolean flush()Flush the log data if the log auto flush is turned off WARNING: This will replace all the log file content, this should be used only for applications that runs once -> generate a log file and then switch log file. You can change the log file by overridinggetLoggerFile(LogExtension)DOES NOTHING ONLogger- Returns:
- if the log could be flushed
-
close
public final void close()This means remove the logger name attachment so you can create a new logger instance with new logger options- Specified by:
closein interfaceAutoCloseable
-
getLoggerFile
Get the today's logger file- Parameters:
type- the log extension file type- Returns:
- the today's logger file
-
fetchTime
Get the now's time- Parameters:
type- the calendar type ( gregorian or US )- Returns:
- the now's time
-
printInfo
protected final boolean printInfo()Get if the logger prints info- Returns:
- if the logger prints info
-
printError
protected final boolean printError()Get if the logger prints errors- Returns:
- if the logger prints errors
-
getLogger
Get the requested logger or KarmaAPI's logger if there's not any logger with the provided name- Parameters:
name- the logger name- Returns:
- the logger
-