FileLogHandler class
A implementation of BDCleanableLogHandler that write BDLogRecord to files.
- Inheritance
-
- Object
- BDLogHandler
- BDCleanableLogHandler
- FileLogHandler
Constructors
-
FileLogHandler({required String logNamePrefix, required int maxLogSizeInMb, required int maxFilesCount, required Directory logFileDirectory, List<
BDLevel> supportedLevels = const <BDLevel>[BDLevel.warning, BDLevel.success, BDLevel.error], BDLogFormatter logFormatter = const DefaultLogFormatter()}) - Create a new instance of FileLogHandler.
Properties
- currentLogFile ↔ File
-
The current log file that logs are written to.
If this log file exceeds maxLogSizeInMb, current log file will be closed
and new one will be created with updateCurrentLogFile method
getter/setter pair
- currentLogIndex ↔ int
-
The index of the current log file.
Will be incremented on every update of currentLogFile.
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- logFileDirectory → Directory
-
Directory where to store the log files.
final
- logFormatter → BDLogFormatter
-
BDLogFormatter that define how BDLogRecord should be written.
final
- logNamePrefix → String
-
Prefix of each log files created by this FileLogHandler.
final
- maxFilesCount → int
-
Maximum count of files to keep.
final
- maxLogSizeInMb → int
-
Maximum size of a log file in MB.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
supportedLevels
→ List<
BDLevel> -
Supported
BDLevel
of BDLogRecord.final - writer ↔ RandomAccessFile?
-
The writer to perform operations on the currentLogFile
getter/setter pair
Methods
-
clean(
) → Future< void> -
Clean resources contained within this BDLogHandler.
override
-
getLatestLogFileIndex(
List< File> logFiles) → int -
Get latest log file index from
logFiles
. -
getLogFileIndex(
String fileName) → int -
Get the index of the log file from the
fileName
. -
getLogFiles(
) → List< File> - Get all the log files currently available in logFileDirectory.
-
handleRecord(
BDLogRecord record) → Future< void> -
Handle the BDLogRecord.
override
-
initializeFileSink(
Directory logDir) → RandomAccessFile - Create log file to written to.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onFileExceededMaxSize(
) → void - Called when the current log file exceeded maxLogSizeInMb.
-
removeOldLogFilesIfRequired(
) → void - Remove the old log files if the current count of log files exceed the number of log files.
-
sortFileByIndex(
List< File> logFiles) → List<File> - Sort the list of log files by their log indexes.
-
supportLevel(
BDLevel level) → bool -
Allow the BDLogHandler to specify
which BDLevel of BDLogRecord he can handle.
override
-
toString(
) → String -
A string representation of this object.
inherited
-
updateCurrentLogFile(
Directory logDir) → RandomAccessFile - Updates current log file with a newly created one
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- logFileNameSuffix → const String
- The suffix added after the logNamePrefix followed by the log file index.