module Earl::Logger
Overview
Requires Earl.application
to be started. Otherwise logged messages will
hang the current program when the logger mailbox is full!
Extension module:
Include in agents to add a single #log
method to access Log
methods for
the current agent. The methods eventually delegate to Logger
class methods.
Configuration:
#level=
—change theSeverity
level (default:Severity::INFO
).#backends
—add or remove backends (default:ConsoleBackend
).
The configuration may be changed at any time, but we advise to configure
once before starting Earl.application
.
Custom backends:
Custom backends must inherit from Backend
and implement the
Backend#write
abstract method.
Direct including types
Defined in:
logger.crlogger/actor.cr
logger/backend.cr
logger/console_backend.cr
logger/severity.cr
Class Method Summary
-
.backends : Array(Backend)
The list of currently enabled backends.
-
.debug(agent : Agent, message : String) : Nil
Logs message if
.debug?
returns true. -
.debug(agent : Agent, &block : -> String) : Nil
Logs the message returned by the block if
.debug?
returns true, otherwise the block is never invoked. -
.debug? : Bool
Returns true if the current level is DEBUG or lower.
-
.error(agent : Agent, message : String) : Nil
Logs message if
.error?
returns true. -
.error(agent : Agent, &block : -> String) : Nil
Logs the message returned by the block if
.error?
returns true, otherwise the block is never invoked. - .error(agent : Agent, ex : Exception)
-
.error? : Bool
Returns true if the current level is ERROR or lower.
-
.info(agent : Agent, message : String) : Nil
Logs message if
.info?
returns true. -
.info(agent : Agent, &block : -> String) : Nil
Logs the message returned by the block if
.info?
returns true, otherwise the block is never invoked. -
.info? : Bool
Returns true if the current level is INFO or lower.
- .level : Severity
-
.level=(severity : Severity) : Severity
Configures the severity level.
-
.silent? : Bool
Returns true if the current level is SILENT.
-
.warn(agent : Agent, message : String) : Nil
Logs message if
.warn?
returns true. -
.warn(agent : Agent, &block : -> String) : Nil
Logs the message returned by the block if
.warn?
returns true, otherwise the block is never invoked. -
.warn? : Bool
Returns true if the current level is WARN or lower.
Instance Method Summary
Class Method Detail
The list of currently enabled backends. Can be modified to add, remove or
configure backends, but must be done before starting Earl.application
.
Custom backends must inherit from Backend
.
Logs message if .debug?
returns true.
Logs the message returned by the block if .debug?
returns
true, otherwise the block is never invoked.
Logs message if .error?
returns true.
Logs the message returned by the block if .error?
returns
true, otherwise the block is never invoked.
Logs message if .info?
returns true.
Logs the message returned by the block if .info?
returns
true, otherwise the block is never invoked.
Configures the severity level. Can be changed at any time.
Logs message if .warn?
returns true.
Logs the message returned by the block if .warn?
returns
true, otherwise the block is never invoked.