Class FileController
java.lang.Object
java.util.logging.Handler
java.util.logging.StreamHandler
java.util.logging.FileHandler
com.clumd.projects.java_custom_logging.logging.controllers.FileController
- All Implemented Interfaces:
CustomLogHandler
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionFileController(String pathToLogFile, int singleFileLogSize, int logFileRotations, boolean appendMode) Pass-through constructor ensuring we will use the desired custom formatter, and match ALL records. -
Method Summary
Modifier and TypeMethodDescriptionvoidacceptLogRootRefs(@NonNull UUID specificRunID, @NonNull String systemID, @NonNull Map<Long, String> overriddenThreadNames) A method to act as an initialiser for any Custom Log ControllerbooleanisLoggable(LogRecord logRecord) voidsetFormatter(Formatter newFormatter) Methods inherited from class java.util.logging.FileHandler
close, publishMethods inherited from class java.util.logging.StreamHandler
flush, setEncoding, setOutputStreamMethods inherited from class java.util.logging.Handler
getEncoding, getErrorManager, getFilter, getFormatter, getLevel, reportError, setErrorManager, setFilter, setLevel
-
Field Details
-
fileDateTimeFormatter
-
-
Constructor Details
-
FileController
public FileController(String pathToLogFile, int singleFileLogSize, int logFileRotations, boolean appendMode) throws IOException, SecurityException Pass-through constructor ensuring we will use the desired custom formatter, and match ALL records.- Parameters:
pathToLogFile- The pattern to match for the logfile's title.singleFileLogSize- This is the max file size before the logger will rotate files (in regular Bytes).logFileRotations- This is the max number of log files to keep in rotation before overwriting the first one.appendMode- Should always be true to ensure we are in append mode.- Throws:
IOException- Thrown if we cannot find the location or there is an error getting it.SecurityException- Thrown if we do not have the correct permissions to be writing to this location.
-
-
Method Details
-
acceptLogRootRefs
public void acceptLogRootRefs(@NonNull @NonNull UUID specificRunID, @NonNull @NonNull String systemID, @NonNull @NonNull Map<Long, String> overriddenThreadNames) Description copied from interface:CustomLogHandlerA method to act as an initialiser for any Custom Log Controller- Specified by:
acceptLogRootRefsin interfaceCustomLogHandler- Parameters:
specificRunID- A unique identifier for any given specific 'run' of the system.systemID- An identifier for the hostname of the hardware running this instance.overriddenThreadNames- A map between ThreadIDs and their human-readable names, perhaps describing what they do.
-
isLoggable
- Overrides:
isLoggablein classStreamHandler
-
setFormatter
- Overrides:
setFormatterin classHandler- Throws:
SecurityException
-