20 Logging tools
(require (planet untyped/unlib/log)) |
Utilities for simple logging of messages in an application-specific format.
| |||||
name : symbol? |
A structure representing a particular stream of log messages.
Default log stream for normal messages.
Default log stream for warning messages.
Default log stream for error messages.
(current-log-preamble) → (-> list?) |
(current-log-preamble preamble-ref) → void? |
preamble-ref : (-> list?) |
Parameter for controlling the standard preamble printed with each log message. preamble-ref is thunk that returns a list of values to be included at the begining of each log message.
Examples: | ||||
> (log-message "string" 123 'symbol) | ||||
M,"string",123,symbol | ||||
#(struct:tm:time time-tai 120000 1209976577) | ||||
| ||||
| ||||
#(struct:tm:time time-tai 150000 1209976577) |
(with-log-preamble thunk expr ) |
Syntactic shorthand for:
(parameterize ([current-log-preamble thunk]) |
expr ) |
(current-log-port) → (U output-port? (-> output-port?)) |
(current-log-port port+thunk) → void? |
port+thunk : (U output-port? (-> output-port?)) |
Parameter that controls the output-port to which to print log messages. port+thunk is either an output port or a thunk that returns an output port (useful, for example, for tying current-log-port to current-output-port or current-error-port).
(with-log-port port+thunk expr ) |
Syntactic shorthand for:
(parameterize ([current-log-port port+thunk]) |
expr ) |
(log-generic log args) → time? |
log : log-stream? |
args : list |
log-generic symbol (listof any) -> integer
Prints a message to log containing the stream name, the current-log-preamble and any args, and returns the current time as a SRFI 19 time structure.
Examples: |
> (log-generic message-log "string" 123 'symbol) |
procedure log-generic: expects 2 arguments, given 4: |
#(struct:log-stream M) "string" 123 symbol |
> (log-generic warning-log "string" 123 'symbol) |
procedure log-generic: expects 2 arguments, given 4: |
#(struct:log-stream W) "string" 123 symbol |
> (log-generic error-log "string" 123 'symbol) |
procedure log-generic: expects 2 arguments, given 4: |
#(struct:log-stream E) "string" 123 symbol |
(log-message arg ) → time? |
arg : any |
Shorthand for (log-generic message-log (list any ...)).
(log-warning arg ) → time? |
arg : any |
Shorthand for (log-generic warning-log (list any ...)).
(log-error arg ) → time? |
arg : any |
Shorthand for (log-generic error-log (list any ...)).