Package dev.alphagame.trailblazer.utils
Class FileLoggerUtils
java.lang.Object
dev.alphagame.trailblazer.utils.FileLoggerUtils
Utility class for creating file-based loggers.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic TBLogger
createFileLogger
(String name, String filePath) Creates a logger that writes to a file using the SimpleFormatter with INFO level.static TBLogger
createFileLogger
(String name, String filePath, LogLevel logLevel) Creates a logger that writes to a file using the SimpleFormatter.static TBLogger
createJSONFileLogger
(String name, String filePath) Creates a JSON logger that writes to a file with INFO level.static TBLogger
createJSONFileLogger
(String name, String filePath, LogLevel logLevel) Creates a JSON logger that writes to a file.static TBLogger
createRotatingFileLogger
(String name, String filePath, LogLevel logLevel, long maxSizeBytes) Creates a rotating file logger (simple implementation).
-
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
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.
-