Class KarmaLogger

java.lang.Object
ml.karmaconfigs.api.common.utils.KarmaLogger
All Implemented Interfaces:
AutoCloseable
Direct Known Subclasses:
BufferedLogger, Logger

public abstract class KarmaLogger extends Object implements AutoCloseable
Karma logger
  • Constructor Details

    • KarmaLogger

      public KarmaLogger(KarmaSource owner)
      Initialize the karma logger
      Parameters:
      owner - the logger owner
    • KarmaLogger

      public KarmaLogger(KarmaSource owner, boolean autoFlush, boolean errors, boolean messages)
      Initialize the karma logger
      Parameters:
      owner - the logger owner
      autoFlush - auto flush log files
      errors - display errors as messages too
      messages - display messages as console messages too
  • Method Details

    • scheduleLog

      public abstract void scheduleLog(Level level, CharSequence info, Object... replaces)
      Run the log function on a new thread
      Parameters:
      level - the log level
      info - the info to log
      replaces - the info replaces
    • scheduleLog

      public abstract void scheduleLog(Level level, Throwable error)
      Run the log function on a new thread
      Parameters:
      level - the log level
      error - 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 level
      print - print info to console
      info - the info to log
      replaces - the info replaces
    • scheduleLogOption

      public abstract void scheduleLogOption(Level level, boolean print, Throwable error)
      Run the log function on a new thread
      Parameters:
      level - the log level
      print - print info to console
      error - the error to log
    • syncedLog

      public abstract void syncedLog(Level level, CharSequence info, Object... replaces)
      Run the log function on the main known thread
      Parameters:
      level - the log level
      info - the info to log
      replaces - the info replaces
    • syncedLog

      public abstract void syncedLog(Level level, Throwable error)
      Run the log function on the main known thread
      Parameters:
      level - the log level
      error - 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 level
      print - print info to console
      info - the info to log
      replaces - the info replaces
    • syncedLogOption

      public abstract void syncedLogOption(Level level, boolean print, Throwable error)
      Run the log function on the main known thread
      Parameters:
      level - the log level
      print - print info to console
      error - 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 overriding getLoggerFile(LogExtension) DOES NOTHING ON Logger
      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:
      close in interface AutoCloseable
    • getLoggerFile

      protected Path getLoggerFile(LogExtension type)
      Get the today's logger file
      Parameters:
      type - the log extension file type
      Returns:
      the today's logger file
    • fetchTime

      protected String fetchTime(LogCalendar type)
      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

      @Nullable public static @Nullable KarmaLogger getLogger(String name)
      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