class
SimpLog::FileBackend
- SimpLog::FileBackend
- Log::IOBackend
- Log::Backend
- Reference
- Object
Overview
Provides a Log::Backend that is backed with a log file that
supports automatic rotation, compression, and purging at specified
durations
Defined in:
simplog.crConstant Summary
-
DATETIME_FORMAT =
"%Y%m%d%H%M%S%3N" -
Datetime pattern used to suffix rotated file names
-
DEFAULT_COMPRESS_AFTER =
7.days -
Default compress duration: logs will be compress after 1 week
-
DEFAULT_DISPATCH_MODE =
::Log::DispatchMode::Async -
Default
Log::DispatchMode -
DEFAULT_GZIP_EXTENSION =
".gz" -
Default file extension used for gzip compressed log files
-
DEFAULT_ROTATE_AT =
1.day -
Default rotation duration: logs will be rotated after 1 day
Constructors
-
.new(filename : String, *, formatter : Log::Formatter = ::Log::ShortFormat, dispatcher : Log::Dispatcher::Spec = DEFAULT_DISPATCH_MODE)
Creates a new LogFileBackend, filename should use .log extension for log retention to work correctly and ideally use a dedicated directory
-
.new(*, formatter : Log::Formatter = ::Log::ShortFormat, dispatcher : Log::Dispatcher::Spec = DEFAULT_DISPATCH_MODE)
Creates a new LogFileBackend with a log filename inferred from the executable filename
Instance Method Summary
-
#close : Nil
Closes underlying resources used by this backend including the log file
-
#compress_after : Time::Span
File age at which log files will be gzip compressed
-
#compress_after=(compress_after : Time::Span)
File age at which log files will be gzip compressed
-
#delete_after : Time::Span | Nil
File age at which log files will be purged, if not set logs will be retained forever by default
-
#delete_after=(delete_after : Time::Span | Nil)
File age at which log files will be purged, if not set logs will be retained forever by default
- #filename : String
-
#format(entry : Log::Entry) : Nil
Emits the entry to the log file, using the
#formatterto convert -
#next_rotation_at : Time
When the next log file rotation is scheduled to occur
-
#rotate_at : Time::Span
File age at which the current log file will be rotated
-
#rotate_at=(rotate_at : Time::Span) : Nil
Sets the age at which the log file will be rotated
-
#write(entry : Log::Entry) : Nil
Writes an entry to the log file, first rotating the log file if required
Constructor Detail
Creates a new LogFileBackend, filename should use .log extension for log retention to work correctly and ideally use a dedicated directory
Creates a new LogFileBackend with a log filename inferred from the executable filename
Instance Method Detail
File age at which log files will be gzip compressed
File age at which log files will be purged, if not set logs will be retained forever by default
File age at which log files will be purged, if not set logs will be retained forever by default
Emits the entry to the log file, using the #formatter to convert
Writes an entry to the log file, first rotating the log file if required