Private

Private

Loggers

Base.infoFunction.
info(logger::Logger, msg::AbstractString)

Logs the message at the info level.

info(msg::Function, logger::Logger)

Logs the message produced by the provided function at the info level.

source
Base.logMethod.
log(::Function, ::Logger, ::AbstractString)

Same as log(logger, level, msg), but in this case the message can be a function that returns the log message string.

Arguments

  • msg::Function: a function that returns a message String

  • logger::Logger: the logger to log to.

  • level::AbstractString: the log level as a String

Throws

  • CompositeException: may be thrown if an error occurs in one of the handlers (which are run with @async)

source
Base.logMethod.
log(logger::Logger, level::AbstractString, msg::AbstractString)

Creates a Dict with the logger name, level, levelnum and message and calls the other log method (which may recursively call itself on parent loggers with the created Dict).

Arguments

  • logger::Logger: the logger to log to.

  • level::AbstractString: the log level as a String

  • msg::AbstractString: the msg to log as a String

Throws

  • CompositeException: may be thrown if an error occurs in one of the handlers (which are run with @async)

source
Base.logMethod.
log(logger::Logger, args::Dict{Symbol, Any})

Logs logger.record(args) to its handlers if it has the appropriate args[:level] and args[:level] is above the priority of logger.level. If this logger is not the root logger and logger.propagate is true then the parent logger is called.

NOTE: This method calls all handlers asynchronously and is recursive, so you should call this method with a @sync in order to synchronize all handler tasks.

Arguments

  • logger::Logger: the logger to log args to.

  • args::Dict: a dict of msg fields and values that should be passed to logger.record.

source
Base.push!Method.
push!(logger::Logger, filter::Memento.Filter)

Adds an new Filter to the logger.

source
Base.push!Method.
push!(logger::Logger, handler::Handler)

Adds a new Handler to the logger.

source
Base.showMethod.
Base.show(::IO, ::Logger)

Just prints Logger(logger.name)

source
Base.warnFunction.
warn(logger::Logger, msg::AbstractString)

Logs the message at the warn level.

warn(msg::Function, logger::Logger)

Logs the message produced by the provided function at the warn level.

source
Base.warnMethod.
warn(logger::Logger, exc::Exception)

Takes an exception and logs it. If the exception is a CompositeException, each contained exception is logged.

source
Memento.config!Method.
config!([logger], level; fmt::AbstractString, levels::Dict{AbstractString, Int}, colorized::Bool) -> Logger

Sets the Memento._log_levels, creates a default root logger with a DefaultHandler that prints to stdout.

Arguments

  • 'logger::Union{Logger, AbstractString}`: The logger to configure (optional)

  • level::AbstractString: the minimum logging level to log message to the root logger (required).

  • fmt::AbstractString: a format string to pass to the DefaultFormatter which describes how to log messages (defaults to Memento.DEFAULT_FMT_STRING)

  • levels: the default logging levels to use (defaults to Memento._log_levels).

  • colorized: whether or not the message to stdout should be colorized.

Returns

  • Logger: the root logger.

source
getchildren(name::AbstractString)

Takes a string representing the name of a logger and returns its children. Child loggers are extracted assuming a naming convention of "foo.bar.baz", where "foo.bar.baz" is the child of "foo.bar" which is the child of "foo".

Arguments

  • name::AbstractString: the name of the logger.

Returns

  • Vector{Logger}

source
Memento.getparentMethod.
getparent(name::AbstractString) -> Logger

Takes a string representing the name of a logger and returns its parent. If the logger name has no parent then the root logger is returned. Parent loggers are extracted assuming a naming convention of "foo.bar.baz", where "foo.bar.baz" is the child of "foo.bar" which is the child of "foo".

Arguments

  • name::AbstractString: the name of the logger.

Returns

  • Logger: the parent logger.

source
Memento.registerMethod.
register(::Logger)

Register an existing logger with Memento.

source
Memento.reset!Method.
reset!()

Removes all registered loggers and reinitializes the root logger without any handlers.

source

Handlers

Base.logMethod.
log(handler::Handler, rec::Record)

Checks the Handler filters and if they all pass then emit the record.

source
Base.push!Method.
push!(handler::DefaultHandler, filter::Memento.Filter)

Adds an new Filter to the handler.

source
Memento.setup_optsMethod.
setup_opts(opts) -> Dict

Sets the default :colors if opts[:is_colorized] == true.

source

Formatters

Records

Base.DictMethod.
Dict(rec::Record)

Extracts the Record and its Attributes into a Dict

Warn

This may be an expensive operation, so you probably don't want to do this for every log record unless you're planning on using every Attribute.

source
Base.getMethod.
get(attr::Attribute{T}) -> T

Run set attr.x to the output of attr.f if attr.x is not already set. We then return the value stored in attr.x

source
Memento.get_lookupMethod.
get_lookup(trace::Attribute{StackTrace})

Returns the top StackFrame for trace if it isn't empty.

source
Memento.get_msgMethod.
get_msg(msg) -> Function

Wraps msg in a function if it is a String.

source
Memento.get_traceMethod.
get_trace()

Returns the StackTrace with StackFrames from the Memento module filtered out.

source

IO

Base.flushMethod.
flush(::FileRoller)

Flushes the current open file.

source
Base.printlnMethod.
println(::FileRoller, ::AbstractString)

Writes the string to a file and creates a new file if we've reached the max file size.

source
Memento.getfileMethod.
getfile(folder::AbstractString, prefix::AbstractString) -> String, IO

Grabs the next log file.

source
Memento.getsuffixMethod.
getsuffix(::Integer) -> String

Formats the nth file suffix.

source