Did you know ... | Search Documentation: |
![]() | Pack log4p -- README.md |
A simple logging library for Prolog, inspired by log4j.
This is a package for SWI-Prolog, installable using the built-in package manager with the package name log4p
.
?- pack_install(log4p).
The basic model for logging involves a few simple concepts.
trace
, debug
, info
, warn
, error
, fatal
. If the current log level is set to info
, for example, then message of debug
or to further left in that list will not be given to a handler.
Generating messages is usually a matter of using a number of predicates named for each level: info/1, info/2, warn/1, warn/2 etc. The `/1` variant logs a constant string (or term rendered as a string). The `/2` variant takes a format string and an array of arguments, then calls swritef
to generate a constant string which is then passed onto log handlers.
The current level can be set using the set_log_level/2 predicate, which will also return the previous value.
To add or remove log handlers, use add_log_handler/1 and remove_log_handler/1 respectively.