9.1
Logging
| (require "simple-log") | package: base |
1 Overview
Small wrapper around logger with per-logger callbacks.
A logger consists of a logger, a log-receiver (level 'debug), a mutable callback list, five logging procedures, and a background thread dispatching messages.
2 Definition
Creates:
(make-logger 'id parent)
(make-log-receiver ... 'debug)
callback list
procedures dbg-id, info-id, warn-id, err-id, fatal-id
Starts a thread that syncs on the receiver and forwards messages to callbacks.
3 Logging functions
Formats with (apply format (cons msg args)) and calls log-message.
Attached data:
(list (iso-timestamp) 'id)
4 Callbacks
Registers callback under name. Existing entry
with same name is replaced.
Callback signature:
5 Output helpers
Registers 'display. Output:
topic:level:timestamp:message |
Registers 'file. File opened with
#:exists 'replace. One line per message, flushed.