Class LoggerFactory

java.lang.Object
dev.alphagame.trailblazer.LoggerFactory

public class LoggerFactory extends Object
Factory for creating TBLogger instances. Provides convenient methods for creating loggers with different configurations.
  • Constructor Details

    • LoggerFactory

      public LoggerFactory()
  • Method Details

    • getLogger

      public static TBLogger getLogger(String name)
      Gets a logger with the specified name using the default configuration.
      Parameters:
      name - The name of the logger.
      Returns:
      A TBLogger instance.
    • getLogger

      public static TBLogger getLogger(String name, LogLevel logLevel)
      Gets a logger with the specified name and log level.
      Parameters:
      name - The name of the logger.
      logLevel - The log level.
      Returns:
      A TBLogger instance.
    • getLogger

      public static TBLogger getLogger(String name, LoggerConfiguration configuration)
      Gets a logger with the specified name and configuration.
      Parameters:
      name - The name of the logger.
      configuration - The logger configuration.
      Returns:
      A TBLogger instance.
    • getLogger

      public static TBLogger getLogger(Class<?> clazz)
      Gets a logger for the specified class using the default configuration.
      Parameters:
      clazz - The class to create a logger for.
      Returns:
      A TBLogger instance.
    • getLogger

      public static TBLogger getLogger(Class<?> clazz, LogLevel logLevel)
      Gets a logger for the specified class with the specified log level.
      Parameters:
      clazz - The class to create a logger for.
      logLevel - The log level.
      Returns:
      A TBLogger instance.
    • createSimpleLogger

      public static TBLogger createSimpleLogger(String name)
      Creates a simple logger with the default SimpleFormatter.
      Parameters:
      name - The name of the logger.
      Returns:
      A TBLogger instance with SimpleFormatter.
    • createSimpleLogger

      public static TBLogger createSimpleLogger(String name, LogLevel logLevel)
      Creates a simple logger with the specified log level.
      Parameters:
      name - The name of the logger.
      logLevel - The log level.
      Returns:
      A TBLogger instance with SimpleFormatter.
    • createJSONLogger

      public static TBLogger createJSONLogger(String name)
      Creates a JSON logger that outputs logs in JSON format.
      Parameters:
      name - The name of the logger.
      Returns:
      A TBLogger instance with JSONFormatter.
    • createJSONLogger

      public static TBLogger createJSONLogger(String name, LogLevel logLevel)
      Creates a JSON logger with the specified log level.
      Parameters:
      name - The name of the logger.
      logLevel - The log level.
      Returns:
      A TBLogger instance with JSONFormatter.
    • createColumnedLogger

      public static TBLogger createColumnedLogger(String name)
      Creates a columned logger that outputs logs in columned format.
      Parameters:
      name - The name of the logger.
      Returns:
      A TBLogger instance with ColumnedFormatter.
    • createColumnedLogger

      public static TBLogger createColumnedLogger(String name, LogLevel logLevel)
      Creates a columned logger with the specified log level.
      Parameters:
      name - The name of the logger.
      logLevel - The log level.
      Returns:
      A TBLogger instance with ColumnedFormatter.
    • createLoggerWithStream

      public static TBLogger createLoggerWithStream(String name, PrintStream outputStream)
      Creates a logger that writes to the specified PrintStream.
      Parameters:
      name - The name of the logger.
      outputStream - The output stream to write to.
      Returns:
      A TBLogger instance.
    • setDefaultConfiguration

      public static void setDefaultConfiguration(LoggerConfiguration configuration)
      Sets the default configuration for new loggers created by getLogger methods.
      Parameters:
      configuration - The default configuration.
    • getDefaultConfiguration

      public static LoggerConfiguration getDefaultConfiguration()
      Gets the default configuration.
      Returns:
      The default configuration.
    • clearCache

      public static void clearCache()
      Clears the logger cache.