simple logger egg for CHICKEN scheme
Find a file
2026-01-19 17:10:48 -08:00
.gitignore first commit 2026-01-18 11:11:52 -08:00
LICENSE first commit 2026-01-18 11:11:52 -08:00
logger.egg first commit 2026-01-18 11:11:52 -08:00
logger.release-info fix uri for targz 2026-01-19 17:10:48 -08:00
logger.scm first commit 2026-01-18 11:11:52 -08:00
README.md first commit 2026-01-18 11:11:52 -08:00

logger

Simple structured logging for CHICKEN Scheme with per-module level control.

Usage

(import logger)

;; Basic logging (uses GLOBAL module name)
(logger/d "debug message")
(logger/i "info message")
(logger/w "warning message")
(logger/e "error message")

;; Messages can be concatenated
(logger/i "user " user-id " logged in")

Output:

2026-01-18T19:07:51Z [INFO] [GLOBAL] info message

Per-module logging

Use logger/install inside a module to create local d, i, w, e functions that automatically tag logs with the module name:

(module my-app
  (do-stuff)
  (import scheme chicken.base logger)

  (logger/install my-app)

  (define (do-stuff)
    (i "doing stuff")    ;; tagged as [my-app]
    (d "details...")))

Log levels

Levels from lowest to highest priority: debug, info, warn, error, none

;; Set global level (default: debug)
(logger/level 'info)  ;; hides debug messages

;; Set level for specific module
(logger/set-module-level! 'noisy-module 'warn)

;; Disable a module entirely
(logger/disable-module! 'noisy-module)

Output format

;; Text format (default)
(logger/format 'text)
;; 2026-01-18T19:07:51Z [INFO] [GLOBAL] message

;; JSON format
(logger/format 'json)
;; {"ts":1737226071,"level":"info","module":"GLOBAL","message":"message"}

Custom output port

(import chicken.file.posix)

(call-with-output-file "app.log"
  (lambda (port)
    (logger/output port)
    ;; logs now go to app.log
    ))

License

BSD 3-Clause - see LICENSE file