On this page:
log-fatal*
log-error*
log-warning*
log-info*
log-debug*
start-log-output
current-log-formatter

18 Logging utilities

 (require (planet untyped/unlib/log))
This module adds some useful features to the core logging functionality of PLT Scheme:
  • an application log to which application-level messages may be logged (several Untyped libraries write to this log);

  • application log messages can be timestamped;

  • standard debugging information can be included in application log messages;

  • special application logging macros are provided that allow multiple arguments of any type.

Application log messages are not reported until a call is made to start-log-output, or until a call is made to log-receiver.

(log-fatal* any ...)
Adds a fatal error message to the application log. The arguments are formatted them into a single-line log message together with the message level and current time. The time is returned as a SRFI 19 time-utc?.

(log-error* any ...)
Adds a non-fatal error message to the application log. Behaviour is similar to that of log-fatal*.

(log-warning* any ...)
Adds a warning message to the application log. Behaviour is similar to that of log-fatal*.

(log-info* any ...)
Adds an informational message to the application log. Behaviour is similar to that of log-fatal*.

(log-debug* any ...)
Adds a debugging message to the application log. Behaviour is similar to that of log-fatal*.

(start-log-output level [handler])  (-> void?)
  level : (U 'fatal 'error 'warning 'info 'debug)
  handler : handler-procedure = default-log-handler
Starts a thread that handles application lof messages of the specified level or above. Returns a thunk that stops the logging thread and terminates output.

handler is called each time a message is logged, and should accept three arguments:
  • the level of the message (U 'fatal 'error 'warning 'info 'debug);

  • the message to log (a string);

  • the continuation marks at the point of log entry (a continuation-mark-set).

If handler is omitted, a default-handler-procedure is used that prints all messages to the current-output-port.

(current-log-formatter)
  (log-level time-utc? list? -> string?)
(current-log-formatter formatter)  void?
  formatter : (log-level time-utc? list? -> string?)
Parameter that customises the formatting of application log messages. The value must be a procedure that takes three arguments:

  • the log level ('fatal, 'error, 'warning, 'info or 'debug);

  • an entry timestamp (encoded as a SRFI 19 time-utc?);

  • the list of the arguments passed to the logging macro (log-fatal* or equivalent).