Class FileLoggerUtils

java.lang.Object
dev.alphagame.trailblazer.utils.FileLoggerUtils

public class FileLoggerUtils extends Object
Utility class for creating file-based loggers.
  • Constructor Details

    • FileLoggerUtils

      public FileLoggerUtils()
  • Method Details

    • createFileLogger

      public static TBLogger createFileLogger(String name, String filePath, LogLevel logLevel) throws FileNotFoundException
      Creates a logger that writes to a file using the SimpleFormatter.
      Parameters:
      name - The name of the logger.
      filePath - The path to the log file.
      logLevel - The log level.
      Returns:
      A TBLogger that writes to the specified file.
      Throws:
      FileNotFoundException - If the file cannot be created or written to.
    • createFileLogger

      public static TBLogger createFileLogger(String name, String filePath) throws FileNotFoundException
      Creates a logger that writes to a file using the SimpleFormatter with INFO level.
      Parameters:
      name - The name of the logger.
      filePath - The path to the log file.
      Returns:
      A TBLogger that writes to the specified file.
      Throws:
      FileNotFoundException - If the file cannot be created or written to.
    • createJSONFileLogger

      public static TBLogger createJSONFileLogger(String name, String filePath, LogLevel logLevel) throws FileNotFoundException
      Creates a JSON logger that writes to a file.
      Parameters:
      name - The name of the logger.
      filePath - The path to the log file.
      logLevel - The log level.
      Returns:
      A TBLogger that writes JSON to the specified file.
      Throws:
      FileNotFoundException - If the file cannot be created or written to.
    • createJSONFileLogger

      public static TBLogger createJSONFileLogger(String name, String filePath) throws FileNotFoundException
      Creates a JSON logger that writes to a file with INFO level.
      Parameters:
      name - The name of the logger.
      filePath - The path to the log file.
      Returns:
      A TBLogger that writes JSON to the specified file.
      Throws:
      FileNotFoundException - If the file cannot be created or written to.
    • createRotatingFileLogger

      public static TBLogger createRotatingFileLogger(String name, String filePath, LogLevel logLevel, long maxSizeBytes) throws FileNotFoundException
      Creates a rotating file logger (simple implementation). When the file exceeds maxSizeBytes, it will be renamed with .old extension and a new file will be created.
      Parameters:
      name - The name of the logger.
      filePath - The path to the log file.
      logLevel - The log level.
      maxSizeBytes - Maximum file size before rotation.
      Returns:
      A TBLogger that writes to a rotating file.
      Throws:
      FileNotFoundException - If the file cannot be created or written to.