Class Logger

java.lang.Object
com.prineside.tdi2.utils.logging.Logger

public final class Logger extends Object
- Writes logs to a log writer specified by the platform (normally it is a log.txt) - Makes sure to flush and close the log writer if app exits in a regular way - Rotates logs at the start of the game or if they get too big
  • Field Details

    • DEFAULT_LOG_FILE_NAME

      public static final String DEFAULT_LOG_FILE_NAME
      Must be accessible with Gdx.files.local(), not forced - just a suggestion
      See Also:
    • MAX_TAG_SIZE

      public static final int MAX_TAG_SIZE
      See Also:
  • Method Details

    • forClass

      public static TLog forClass(Class<?> clazz)
    • forTag

      public static TLog forTag(String tag)
    • init

      public static void init(ActionResolver actionResolver)
    • forceLogFileFlushAndRun

      public static void forceLogFileFlushAndRun(Runnable onFlush)
      Flush log file asap and run something immediately on the log writer thread
      Parameters:
      onFlush - a piece of code to run once right after flush. Will be called on a separate thread.
    • addLogListener

      public static void addLogListener(Logger.LogListener listener)
    • removeLogListener

      public static void removeLogListener(Logger.LogListener listener)
    • setLogFile

      public static void setLogFile(@Null FileHandle file)
      Set log file output and close the writer if it is opened
      Parameters:
      file - file to write logs to, can be null
    • getPlatformLogger

      public static PlatformLogger getPlatformLogger()
    • setPlatformLogger

      public static void setPlatformLogger(PlatformLogger platformLogger)
    • getLastLogLines

      public static String getLastLogLines(int lineCount)
      Returns:
      last log lines, usually used for reports