Scriba: Structured Logging in Lisp (Guile Scheme)
Scriba introduces an auto-logger feature for structured logging in Lisp, specifically in Guile Scheme. This feature allows for easy configuration of logging behaviors based on the environment, facilitating different logging formats for development and production. The auto-logger can read environment variables to determine the appropriate logger and settings at runtime.
- ▪The auto-logger simplifies the process of setting up loggers by automatically determining configurations based on environment variables.
- ▪It supports different logging formats, such as colorful console logs for development and structured JSON logs for production.
- ▪Logger creation is memoized, ensuring that subsequent calls for the same logger are instant.
Opening excerpt (first ~120 words) tap to expand
While you can instantiate specific loggers manually, the simplest way to get started is with the auto-logger. It reads environment variables (and, in the future, Scheme configuration files) to automatically determine at runtime which logger to use and how to configure it. This is especially useful for maintaining different logging behaviors between development and production environments. A common use-case is to use a pretty and colorful console logger in local development, and structured JSON logging in production, for logs to be parsed and aggregated by tools like Loki. (define-module (my-module) #:use-module (scriba auto) #:use-module (scriba scriba)) (let* ((s (scriba-auto-logger))) (log-info s "Hello Scriba!") (with-log-context `((key-1 .
…
Excerpt limited to ~120 words for fair-use compliance. The full article is at Codeberg.org.