Next: , Previous: , Up: API  


1.6 (scriba layout)

This module holds the plaintext layout shared by Scriba’s text backends (the console and the file logger). Fields are formatted as bracketed blocks and joined in the order requested by the logger’s ‘#:layout‘, so a backend only has to decide where the finished line goes.

Timestamps are cached per format string and per wall-clock second. Formatting a time is by far the most expensive part of a log line (it consults the timezone database), while a second-resolution format cannot change within the same second, so the cache removes that cost from every line but the first one of each second.

1.6.1 Procedures

Procedure: display->string value

Returns VALUE rendered the way ‘display’ would render it.

Strings are returned untouched, so the common case allocates nothing.

Procedure: format-context ctx

Converts an alist context into a bracketed string layout: [k=v] [k=v].

Procedure: format-name name

Returns the formatted logger name, or an empty string.

Procedure: format-plain-time format-string

Returns the current time formatted with FORMAT-STRING, without brackets.

The result is reused for every log line within the same second, because strftime and localtime are much more expensive than the rest of a log line and a second-resolution format cannot change faster than that.

Procedure: format-tags tags

Converts an list of tags into a bracketed string layout: [#a #b #c].

Procedure: format-timestamp format-string

Returns a formatted, bracketed timestamp string.

Procedure: make-text-printer KEY: #:name #:layout #:timestamp-format #:emit

Returns a procedure that turns a log level into a logging procedure.

The returned procedure maps a level symbol (or #t for level-less messages) to a ‘(lambda (msg . args) ...)’ procedure. When called, that procedure formats MSG with ARGS, builds the configured LAYOUT and hands the finished line, without any newline, to EMIT. Backends use EMIT to choose their destination, newline placement and flushing behaviour.


Next: (scriba scriba), Previous: (scriba json), Up: API