Class LoggerFactory
java.lang.Object
com.chrisnewland.freelogj.LoggerFactory
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static DateTimeFormatterprivate static Logger.LogLevelprivate static PrintStream -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic LoggerReturns aLoggerfor the given Class.static voidinitialise(Logger.LogLevel logLevel) Initialise the LoggerFactory with the givenLogger.LogLevel.static voidinitialise(Logger.LogLevel logLevel, PrintStream printStream) Initialise the LoggerFactory with the givenLogger.LogLevelandPrintStream.static voidinitialise(Logger.LogLevel logLevel, PrintStream printStream, DateTimeFormatter dateTimeFormatter) Initialise the LoggerFactory with the givenLogger.LogLevel,PrintStream, andDateTimeFormatterAll loggers created bygetLoggerwill be set at this LogLevel and use this PrintStream and DateTimeFormatter.static voidsetLogFile(Path logFilePath) Set the LoggerFactory PrintStream to use aPrintStreamwrapping aFileOutputStreamopened on the givenPathAll loggers created bygetLoggerwill use this PrintStream.
-
Field Details
-
logLevel
-
printStream
-
dateFormat
-
-
Constructor Details
-
LoggerFactory
public LoggerFactory()
-
-
Method Details
-
initialise
Initialise the LoggerFactory with the givenLogger.LogLevel. All loggers created bygetLoggerwill be set at this LogLevel.- Parameters:
logLevel- The logging level. Messages below this level will not be logged.
-
initialise
Initialise the LoggerFactory with the givenLogger.LogLevelandPrintStream. All loggers created bygetLoggerwill be set at this LogLevel and use this PrintStream.- Parameters:
logLevel- Messages below this level will not be logged.printStream- Messages will be written to this PrintStream.
-
initialise
public static void initialise(Logger.LogLevel logLevel, PrintStream printStream, DateTimeFormatter dateTimeFormatter) Initialise the LoggerFactory with the givenLogger.LogLevel,PrintStream, andDateTimeFormatterAll loggers created bygetLoggerwill be set at this LogLevel and use this PrintStream and DateTimeFormatter.- Parameters:
logLevel- Messages below this level will not be logged.printStream- Messages will be written to this PrintStream.dateTimeFormatter- Messages timestamps will be formatted with this DateTimeFormatter.
-
setLogFile
Set the LoggerFactory PrintStream to use aPrintStreamwrapping aFileOutputStreamopened on the givenPathAll loggers created bygetLoggerwill use this PrintStream.- Parameters:
logFilePath- Path to the log file. If the log file cannot be opened, aRuntimeExceptionis thrown wrapping theFileNotFoundException.
-
getLogger
-