Package dev.alphagame.trailblazer
Class LoggerFactory
java.lang.Object
dev.alphagame.trailblazer.LoggerFactory
Factory for creating TBLogger instances.
Provides convenient methods for creating loggers with different configurations.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
Clears the logger cache.static TBLogger
createColumnedLogger
(String name) Creates a columned logger that outputs logs in columned format.static TBLogger
createColumnedLogger
(String name, LogLevel logLevel) Creates a columned logger with the specified log level.static TBLogger
createJSONLogger
(String name) Creates a JSON logger that outputs logs in JSON format.static TBLogger
createJSONLogger
(String name, LogLevel logLevel) Creates a JSON logger with the specified log level.static TBLogger
createLoggerWithStream
(String name, PrintStream outputStream) Creates a logger that writes to the specified PrintStream.static TBLogger
createSimpleLogger
(String name) Creates a simple logger with the default SimpleFormatter.static TBLogger
createSimpleLogger
(String name, LogLevel logLevel) Creates a simple logger with the specified log level.static LoggerConfiguration
Gets the default configuration.static TBLogger
Gets a logger for the specified class using the default configuration.static TBLogger
Gets a logger for the specified class with the specified log level.static TBLogger
Gets a logger with the specified name using the default configuration.static TBLogger
getLogger
(String name, LoggerConfiguration configuration) Gets a logger with the specified name and configuration.static TBLogger
Gets a logger with the specified name and log level.static void
setDefaultConfiguration
(LoggerConfiguration configuration) Sets the default configuration for new loggers created by getLogger methods.
-
Constructor Details
-
LoggerFactory
public LoggerFactory()
-
-
Method Details
-
getLogger
Gets a logger with the specified name using the default configuration.- Parameters:
name
- The name of the logger.- Returns:
- A TBLogger instance.
-
getLogger
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
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
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
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
Creates a simple logger with the default SimpleFormatter.- Parameters:
name
- The name of the logger.- Returns:
- A TBLogger instance with SimpleFormatter.
-
createSimpleLogger
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
Creates a JSON logger that outputs logs in JSON format.- Parameters:
name
- The name of the logger.- Returns:
- A TBLogger instance with JSONFormatter.
-
createJSONLogger
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
Creates a columned logger that outputs logs in columned format.- Parameters:
name
- The name of the logger.- Returns:
- A TBLogger instance with ColumnedFormatter.
-
createColumnedLogger
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
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
Sets the default configuration for new loggers created by getLogger methods.- Parameters:
configuration
- The default configuration.
-
getDefaultConfiguration
Gets the default configuration.- Returns:
- The default configuration.
-
clearCache
public static void clearCache()Clears the logger cache.
-