Implement logger

This commit is contained in:
Ray Miller 2025-05-29 16:57:26 +01:00
parent 8426126b30
commit 38115b8a57
Signed by: ray
GPG key ID: 043F786C4CD681B8
4 changed files with 94 additions and 11 deletions

View file

@ -8,7 +8,7 @@
(ice-9 format)
(ice-9 match)
((ordo cli run) #:prefix run:)
(srfi srfi-1))
(ordo logger))
(define config
(configuration
@ -20,7 +20,7 @@
(setting
(name 'log-level)
(handler string->symbol)
(test symbol?)
(test valid-log-level?)
(default 'NOTICE)
(example "DEBUG|INFO|NOTICE|WARN|ERROR")
(synopsis "Log level"))))
@ -36,7 +36,13 @@
(define (main cmd-line)
(let ((options (getopt-config-auto cmd-line config)))
(match (full-command options)
(("ordo" "run")
(run:handler options))
(_ (emit-help options)))))
(dynamic-wind
(lambda ()
(setup-logging! #:level (option-ref options 'log-level)))
(lambda ()
(match (full-command options)
(("ordo" "run")
(run:handler options))
(_ (emit-help options))))
(lambda ()
(shutdown-logging!)))))