Previous: , Up: API  


1.4 (scriba scriba)

1.4.1 Macros

Macro: memoize-logger x

Wraps a logger FACTORY-PROC with a caching layer.

Returns a new variadic procedure that accepts arbitrary keyword arguments (KWARGS). When called, it checks a private hash table to see if a logger has already been instantiated with the exact same KWARGS. If so, it returns the cached instance. If not, it calls FACTORY-PROC with the KWARGS, caches the resulting new logger, and returns it.

This ensures that multiple requests for identically configured loggers (e.g., the same name, level, and format) resolve instantly to the exact same object in memory, preventing redundant instantiations and reducing overhead.

Macro: with-log-context x

Dynamically append CTX (an alist) to the current log context for the duration of BODY.

1.4.2 Parameters

Parameter: current-log-context

Default value:

()
Parameter: default-log-level

Default value:

info
Parameter: default-logger

Default value:

"console"
Parameter: default-time-format

Default value:

"%F %T %Z"
Parameter: default-with-timestamp?

Default value:

#t

1.4.3 Procedures

Procedure: is-in-log-level? a b

Is log level A allowed in a B context?

Procedure: log-critical logger message . args

Emits a CRITICAL level log.

Use this for severe, unrecoverable failures that usually require immediate attention, cause data loss, or force the application to abort. MESSAGE is a format string applied to the optional ARGS.

Procedure: log-debug logger message . args

Emits a DEBUG level log.

Use this for diagnostic information helpful to developers when troubleshooting, but generally too noisy to be left enabled in production environments. MESSAGE is a format string applied to the optional ARGS.

Procedure: log-error logger message . args

Emits an ERROR level log.

Use this to record failed operations or exceptions that prevent a specific task from completing, even if the application as a whole can continue running. MESSAGE is a format string applied to the optional ARGS.

Procedure: log-info logger message . args

Emits an INFO level log.

Use this to highlight the normal, high-level progression of the application, such as service startups, configuration loads, or periodic heartbeat events. MESSAGE is a format string applied to the optional ARGS.

Procedure: log-success logger message . args

Emits a SUCCESS level log.

Use this to explicitly indicate the successful completion of a significant operation, task, or transaction. MESSAGE is a format string applied to the optional ARGS.

Procedure: log-trace logger message . args

Emits a TRACE level log.

Use this for the most fine-grained, verbose informational events, such as step-by-step execution traces, loops, or variable dumps. MESSAGE is a format string applied to the optional ARGS.

Procedure: log-warning logger message . args

Emits a WARNING level log.

Use this to flag unexpected or potentially harmful situations that the application can gracefully recover from, such as deprecated API usage or temporary network retries. MESSAGE is a format string applied to the optional ARGS.

Procedure: make-filtered-logger KEY: #:name #:level #:log-trace-proc #:log-debug-proc #:log-info-proc #:log-success-proc #:log-warning-proc #:log-error-proc #:log-critical-proc

Creates a logger, mapping excluded log levels to log-unit.

1.4.4 Variables

Variable: human-time-format
"%F %T %Z"
Variable: iso-8601-time-format
"%Y-%m-%dT%H:%M:%S%z"
Variable: log-friendly-time-format
"%F %T %z"
Variable: log-levels
(trace debug info success warning error critical)

Previous: (scriba json), Up: API