|Did you know ...||Search Documentation:|
|Packs (add-ons) for SWI-Prolog|
|Title:||Logging for Prolog|
|Rating:||Not rated. Create the first rating!|
|Author:||Phil Hargett <firstname.lastname@example.org>|
|Maintainer:||Phil Hargett <email@example.com>|
|Packager:||Phil Hargett <firstname.lastname@example.org>|
No reviews. Create the first review!.
A simple logging library for Prolog, inspired by log4j.
The basic model for logging involves a few simple concepts.
fatal. If the current log level is set to
info, for example, then message of
debugor 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. If the currently effective log level for the calling thread is not equal to or "higher" (e.g., more to the right in the above list of log levels), then the message will be filtered out and not delivered to any handlers.
The effective log level is a layered per-thread choice, depending on which settings are specified:
infoas the log level to assume if no other setting has been specified for the current thread.
global_log_level: any configured global level overrides the default for all threads, new or existing. A global setting remains in place until its cleared with
local_log_level: if a level has been specified for the current thread, then this value will override any global setting, even if the global value is later changed. Using
clear_local_log_levelwill remove any local setting, thus resetting the thread's level to either the global or default level. The current level can be set using the any of the following techniques:
Log handlers disseminate messages to an output desintation, such as
stderr or a log file. To add or remove log handlers, use add_log_handler/1 and remove_log_handler/1 respectively. A log handler is a simple function that simply takes 2 arguments: the
level of the message, and the
message etc. (after formatting).
Pack contains 7 files holding a total of 10.8K bytes.