log
The log
library provides a unified logging interface shared by core
libraries and apps.
packages
LOG/TESTS LOG dependencies
std io obj dependents
gui krypt box/tests box vc ffmpeg/tests ffmpeg jack glib/tests glib gstreamer/tests gstreamer cuda blas math/tests dsp organ doc/tests doc q/tests q rocksdb rdb/tests rdb nlp/tests cry rt net dat log/tests cli core bin/vc files
pkg.lisp condition.lisp log.lisp db.lisp stream.lisp cfg.lisp sys.lisp tests
DATABASE-LOGGER STOP-LOGGER FAST-STREAM STREAM SIMPLE-LOG ROTATING-FILE-LOGGER FILE-LOGGER SIMPLE-LOGGER SIMPLE-LOG-MESSAGE symbols
LOG-TIMESTAMP-FORMAT LOG-INDENT LOG-P TRACE! LOG-CONFIG ROTATING-FILE-SINK DEFAULT-LOGGER ERROR-P FATAL-DESCRIBE LOG-TIMESTAMP-SOURCE LOG-LEVELS LOG-ROUTER-P ALIEN-SOURCE RESTART-LOGGER WARN! SIMPLE-LOG-MESSAGE LEVEL-FILTER %LOG-OBJECT LOG-TIMESTAMP LOG! DATABASE-LOGGER LOG-MESSAGE REMOVE-LOGGER DB-SINK GET-REAL-TIME-SINCE DB-SOURCE MAKE-LOGGER FATAL-P LOGGER LOG-DESCRIBE ILEVEL LOG-MESSAGE-CLASS DEFINE-LOG-LEVEL TAG-FILTER TRACE-DESCRIBE LOG-PIPE WARN-DESCRIBE ALIEN-SINK INFO! SIMPLE-LOG-MESSAGE-FORMATTER LOGGER-CONFIG ERROR-DESCRIBE TRACE-P OCTETS-TO-LOG-MESSAGE LEVEL LOG-OBJECT INFO-DESCRIBE DEBUG-DESCRIBE LOG-ROTATE FATAL! LOG-ERROR WITH-LOGGER LOGGER DEFAULT-LOGGER-CONFIG DEBUG-P LOGGER-P MESSAGE-THREAD WITH-LOG-STREAM LOG-LEVEL LOG-ROUTER TAG-SEPARATOR INIT-LOG-TIMESTAMP TAG-TREE-FILTER LOG-MESSAGE-TO-OCTETS LOG-LEVEL-DESIGNATOR MATCHING-TREE-TAG ALIEN-LOGGER WITH-FAST-LOG-STREAM INFO-P DEBUG! LOG-SHOW-BACKTRACE MAKE-LOG-ROUTER ERROR! WARN-P
Log Levels
A log level is a symbol which may be used as the value of the
*log-level*
variable, which determines the current level of
verbosity.
All possible values of *log-level*
are stored in the *log-levels*
variable:
*log-levels*
T | :TRACE | :DEBUG | :INFO | :WARN | :ERROR | :FATAL | NIL |
Note that the actual position of log-levels in the *log-level*
vector implies the precedence of that level. For example :trace
has the lowest precedence, and will not be printed unless the
*log-level*
is either :trace
or t
. :fatal
hash the highest
precence and will always be printed unless *log-level*
is eql to
nil
.
Loggers
The logger
class implements the multi-threaded object-based logging
protocol which is built atop the std/pipe
protocol.
(documentation 'logger 'type)
A class which implements logging functionality. An instance of this class may be designated as the 'global' logger by setting the value of *LOGGER*, or may be implemented for a specific application.
(sb-mop:class-direct-superclasses (find-class 'logger))
(#<STANDARD-CLASS STD/PIPE:PIPE>)
The global *logger*
variable defaults to nil - it is up to the user
to build a logger instance and start
it. When there is no global
logger set, the Logging Functions will print to *trace-output*
directly while still respecting the *log-level*
.
Configuration
When setting up logging for your application, it is recommended to
subclass the logger-config
class, which implements the obj/config
protocol.
(describe (default-logger-config))
#<LOG:LOGGER-CONFIG {121AC915E3}> [standard-object] Slots with :INSTANCE allocation: AST = ((LEVEL-FILTER :ID :LEVEL-FILTER :LEVEL :INFO).. SIZE = 10 LEVEL = :INFO
The ast
slot stores an unevaluated pipe
used to initialized the
logger resulting from the build
method.
(ast (default-logger-config))
((LEVEL-FILTER :ID :LEVEL-FILTER :LEVEL :INFO) (TAG-TREE-FILTER :ID :TAG-FILTER) (STREAM-SINK :ID :SINK))
Logging Functions
There are two logging functions to keep in mind for each log level - a
predicate and a printer. Using the :info
log-level as an example
the predicate is info-p
and the printer is info!
.
The predicate functions accept no arguments and check the current
precedence of *log-level*
, returning t
if the associated printer
has an equal to or higher precedence than the current level and thus
should print messages. For example the info-p
function will return
t
when *log-level*
is one of :info
, :debug
, :trace
, or t
.