Public
Loggers
Memento.Logger — Type.LoggerA Logger is responsible for converting msg strings into Records which are then passed to each handler. By default loggers propagate their message to their parent loggers.
Fields
name::AbstractString: is the name of the logger (required).handlers::Dict{Any, Handler}: is a collection ofHandlers (defaults to emptyDict).level::AbstractString: the current minimum logging level for the logger to log message to handlers (defaults to "not_set").levels::Dict{AbstractString, Int}: a mapping of available logging levels to their relative priority (represented as integer values) (defaults to usingMemento._log_levels)record::Type: theRecordtype that should be produced by this logger (defaults toDefaultRecord).propagate::Bool: whether or not this logger should propagate its message to its parent (defaults totrue).
Base.error — Function.error(logger::Logger, msg::AbstractString)Logs the message at the error level and throws an ErrorException with that message
error(msg::Function, logger::Logger)Logs the message produced by the provided function at the error level and throws an ErrorException with that message.
error(logger::Logger, exc::Exception)Calls error(logger, msg) with the contents of the Exception, then throw the Exception. If the exception is a CompositeException, each contained exception is logged, then the CompositeException is thrown.
Memento.addlevel! — Method.addlevel!(logger::Logger, level::AbstractString, val::Int)Adds a new level::String and priority::Int to the logger.levels
Memento.alert — Function.alert(logger::Logger, msg::AbstractString)Logs the message at the alert level and throws an ErrorException with that message
alert(msg::Function, logger::Logger)Logs the message produced by the provided function at the alert level and throws an ErrorException with that message.
alert(logger::Logger, exc::Exception)Calls alert(logger, msg) with the contents of the Exception, then throw the Exception. If the exception is a CompositeException, each contained exception is logged, then the CompositeException is thrown.
Memento.critical — Function.critical(logger::Logger, msg::AbstractString)Logs the message at the critical level and throws an ErrorException with that message
critical(msg::Function, logger::Logger)Logs the message produced by the provided function at the critical level and throws an ErrorException with that message.
critical(logger::Logger, exc::Exception)Calls critical(logger, msg) with the contents of the Exception, then throw the Exception. If the exception is a CompositeException, each contained exception is logged, then the CompositeException is thrown.
Memento.debug — Function.debug(logger::Logger, msg::AbstractString)Logs the message at the debug level.
debug(msg::Function, logger::Logger)Logs the message produced by the provided function at the debug level.
Memento.emergency — Function.emergency(logger::Logger, msg::AbstractString)Logs the message at the emergency level and throws an ErrorException with that message
emergency(msg::Function, logger::Logger)Logs the message produced by the provided function at the emergency level and throws an ErrorException with that message.
emergency(logger::Logger, exc::Exception)Calls emergency(logger, msg) with the contents of the Exception, then throw the Exception. If the exception is a CompositeException, each contained exception is logged, then the CompositeException is thrown.
Memento.getfilters — Method.getfilters(logger::Logger) -> Array{Filter}Returns the filters for the logger.
Memento.gethandlers — Method.gethandlers(logger::Logger)Returns logger.handlers
Memento.getlevel — Method.getlevel(::Logger)Returns the current logger level.
Memento.getlogger — Function.getlogger(name::AbstractString) -> LoggerIf the logger or its parents do not exist then they are initialized with no handlers and not set.
Arguments
name::AbstractString: the name of the logger (defaults to "root")
Returns
Logger: the logger.
Memento.getlogger — Method.getlogger(name::Module) -> LoggerConverts the Module to a String and calls get_logger(name::String).
Arguments
name::Module: the Module a logger should be associated
Returns
Logger: the logger associated with the provided Module.
Returns the logger.
Memento.ispropagating — Method.ispropagating(::Logger)Returns true or false as to whether the logger is propagating.
Memento.isroot — Method.isroot(::Logger)Returns true if logger.nameis "root" or ""
Memento.isset — Method.isset(::Logger)Returns true or false as to whether the logger is set. (ie: logger.level != "not_set")
Memento.notice — Function.notice(logger::Logger, msg::AbstractString)Logs the message at the notice level.
notice(msg::Function, logger::Logger)Logs the message produced by the provided function at the notice level.
Memento.setlevel! — Method.setlevel!(f::Function, logger::Logger, level::AbstractString)Temporarily change the level a logger will log at for the duration of the function f.
Memento.setlevel! — Method.setlevel!(logger::Logger, level::AbstractString)Changes what level this logger should log at.
Memento.setpropagating! — Function.setpropagating!([::Function], ::Logger, [::Bool])Sets the logger to be propagating or not (Defaults to true).
Memento.setrecord! — Method.setrecord!{R<:Record}(logger::Logger, rec::Type{R})Sets the record type for the logger.
Arguments
logger::Logger: the logger to set.rec::Record: ARecordtype to use for logging messages (ie:DefaultRecord).
Handlers
Memento.DefaultHandler — Type.DefaultHanlderThe DefaultHandler manages any Formatter, IO and Record.
Fields:
fmt: a
Formatterfor convertingRecords toStringsio: an
IOtype for printingStringto.opts: a dictionary of optional arguments such as :is_colorized and :colors Ex)
Dict{Symbol, Any}( :is_colorized => true, :opts[:colors] => Dict{AbstractString, Symbol}( "debug" => :blue, "info" => :green, ... ) )
Memento.DefaultHandler — Method.DefaultHandler{F}(filename::AbstractString, fmt::F, opts::Dict{Symbol, Any}) where {F<Formatter}Creates a DefaultHandler with a IO handle to the specified filename.
Arguments
filename::AbstractString: the filename of a log file to write tofmt::Formatter: the Formatter to use (default toDefaultFormatter())opts::Dict: the optional arguments (defaults toDict{Symbol, Any}())
Memento.DefaultHandler — Method.DefaultHandler{F, O}(io::O, fmt::F, opts::Dict{Symbol, Any}) where {F<Formatter, O<:IO}Creates a DefaultHandler with the specified IO type.
Arguments
io::IO: the IO typefmt::Formatter: the Formatter to use (default toDefaultFormatter())opts::Dict: the optional arguments (defaults toDict{Symbol, Any}())
Memento.Handler — Type.HandlerManage formatting Records and printing the resulting String to an IO type. All Handler subtypes must implement at least 1 log(::Handler, ::Record) method.
NOTE: Handlers can useful if you need to special case logging behaviour based on the Formatter, IO and/or Record types.
Memento.emit — Method.emit{F, O}(handler::DefaultHandler{F ,O}, rec::Record) where {F<:Formatter, O<:IO}Handles printing any Record with any Formatter and IO types.
Memento.getfilters — Method.getfilters(handler::DefaultHandler) -> Array{Filter}Returns the filters for the handler.
Memento.setlevel! — Method.setlevel!(handler::DefaultHandler, level::AbstractString)Sets the minimum level required to emit the record from the handler.
Formatters
Memento.DefaultFormatter — Type.DefaultFormatterThe DefaultFormatter uses a simple format string to build the log message. Fields from the Record to be used should be wrapped curly brackets.
Ex) "[{level} | {name}]: {msg}" will print message of the form [info | root]: my info message. [warn | root]: my warning message. ...
Memento.DictFormatter — Method.DictFormatter([aliases, serializer])Formats the record to Dict that is amenable to serialization formats such as JSON and then runs the serializer function on the produced dictionary.
Arguments
aliases::Dict{Symbol, Symbol}: Mapping where the keys represent aliases and values represent existing record attributes to include in the dictionary (defaults to all attributes).serializer::Function: A function that takes a Dictionary and returns a string. Defaults tostring(dict).
Memento.Formatter — Type.FormatterA Formatter must implement a format(::Formatter, ::Record) method which takes a Record and returns a String representation of the log Record.
Memento.format — Method.format(::DefaultFormatter, ::Record) -> StringIteratively replaces entries in the format string with the appropriate fields in the Record
Memento.format — Method.format(::DictFormatter, ::Record) -> DictConverts :date, :lookup and :stacktrace to strings and dicts respectively.
Records
Memento.Attribute — Type.AttributeAn Attribute represents a lazily evaluated field in a log Record.
Fields
f::Function: A function to evaluate in order to get a value if one is not set.x::Nullable: A value that may or may not exist yet.
Memento.Attribute — Method.Attribute{T}(f::Function)Creates an Attribute with the function and a Nullable of type T.
Memento.Attribute — Method.Attribute(x)Simply wraps the value x in a Nullable and sticks that in an Attribute with an empty Function.
Memento.DefaultRecord — Type.DefaultRecordStores the most common logging event information. NOTE: if you'd like more logging attributes you can:
add them to DefaultRecord and open a pull request if the new attributes are applicable to most applications.
make a custom
Recordtype.
Fields
date::Attribute{DateTime}: timestamp of log eventlevel::Attribute{Symbol}: log levellevelnum::Attribute{Int}: integer value for log levelmsg::Attribute{AbstractString}: the log message itselfname::Attribute{AbstractString}: the name of the source loggerpid::Attribute{Int}: the pid of where the log event occuredlookup::Attribute{StackFrame}: the top StackFramestacktrace::Attribute{StackTrace}: a stacktrace
Memento.DefaultRecord — Method.DefaultRecord(name::AbstractString, level::AbstractString, msg::AbstractString)Takes a few initial log record arguments and creates a DefaultRecord.
Arguments
name::AbstractString: the name of the source logger.level::AbstractString: the log level.msg::AbstractString: the message being logged.
Memento.Record — Type.RecordAre an Attribute container used to store information about a log events including the msg, date, level, stacktrace, etc. Formatters use Records to format log message strings.
NOTE: you should access Attributes in a Record by using getindex (ie: record[:msg]) as this will correctly extract the value from the Attribute container.
IO
Memento.FileRoller — Type.FileRoller <: IOIs responsible for managing a rolling log file.
Fields
prefix::AbstractString: filename prefix for the log.folder::AbstractString: directory where the log should be written.file::AbstractString: the current file IO handlebyteswritten::Int64: keeps track of how many bytes have been written to the current file.max_sz::Int: the maximum number of bytes written to a file before rolling over to another.
Memento.FileRoller — Method.FileRoller(prefix, dir; max_size=DEFAULT_MAX_FILE_SIZE)Creates a rolling log file in the specified directory with the given prefix.
Memento.FileRoller — Method.FileRoller(prefix; max_size=DEFAULT_MAX_FILE_SIZE)Creates a rolling log file in the current working directory with the specified prefix.