LogRoller.jl
LogRoller.IndexedLogEntry
— TypeIndexedLogEntry represents a log entry as a dictionary and its indexable attributes in a form that is useful to a logging sink.
The index part contains metadata that are to be indexed. Event metadata consists of attributes like level, module, filepath, line, job id, process id, user id, etc. It also includes application specific keywords that the originating piece of code wishes to index.
Keywords that should be considered as metadata are indicated via the indexable
constructor parameter.
What metadata can be indexed depends on the type of sink and whether it has support to index certain types of attributes. Attributes that the sink can not index are made part of the message itself for storage.
The message part can contain the following keys unless they are empty:
metadata
: event metadata that could not be indexedmessage
: the log message stringkeywords
: any keywords provided
Constructor parameters:
log
: Named tuple containing args to the handle_message method, e.g.: (level, message, _module, group, id, file, line, kwargs)indexable
: list of names fromlog
andlog.kwargs
that should be included in the index
LogRoller.LogEntrySerialization
— TypeCustom JSON serializer for log entries. Handles Module types for now, more can be added later.
LogRoller.RollingFileWriter
— TypeA file writer that implements the IO
interface, but only provides write
methods.
Constructor parameters:
- filename: name (including path) of file to log into
- sizelimit: size of file (in bytes) after which the file should be rotated
- nfiles: number of rotated files to maintain
LogRoller.RollingLogger
— TypeRollingLogger(filename, sizelimit, nfiles, minlevel=Info; timestampidentifier::Symbol=:time, format::Symbol=:console) Log into a log file. Rotate log file based on file size. Compress rotated logs.
Logs can be formatted as JSON by setting the optional keyword argument format
to :json
. A JSON formatted log entry is a JSON object. It should have these keys (unless they are empty): The message part can contain the following keys unless they are empty:
metadata
: event metadata e.g. timestamp, line, filename, ...message
: the log message stringkeywords
: any keywords provided
Base.close
— MethodClose any open file handle and streams. A closed object must not be used again.
Base.close
— MethodClose any open file handle and streams. A closed object must not be used again.
Base.write
— MethodWrite into the underlying stream, rolling over as and when necessary.
LogRoller.RollingFileWriterTee
— FunctionTees raw log entries made a RollingFileWriter on to a provided Julia AbstractLogger.
Each line of text is taken as a single log message.
All log entries are made with the same log level, which can be provided during construction. It leaves further examination/parsing of log messages (to extract parameters, or detect exact log levels) to the downstream logger.
LogRoller.postrotate
— MethodRegister a function to be called with the rotated file name just after the current log file is rotated. The file name of the rotated file is passed as an argument. The function is blocking and so any lengthy operation that needs to be done should be done asynchronously.
LogRoller.postrotate
— MethodRegister a function to be called with the rotated file name just after the current log file is rotated. The file name of the rotated file is passed as an argument. The function is blocking and so any lengthy operation that needs to be done should be done asynchronously.
LogRoller.rotate_file
— MethodRotate files as below with increasing age: - <filename> : active file - <filename>1.gz : last rotated file - <filename>2.gz : previous <filename>1.gz rotated to <filename>2.gz - <filename>3.gz : previous <filename>2.gz rotated to <filename>3.gz - ... - <filename>n.gz : last rotated file is discarded when rotated
LogRoller.tee
— MethodTee all lines to the provided logger