grokking simplicity and refactoring

This commit is contained in:
Geir Okkenhaug Jerstad 2025-06-16 13:43:21 +02:00
parent 89a7fe100d
commit fb4361d938
67 changed files with 6275 additions and 56 deletions

View file

@ -0,0 +1,38 @@
;; utils/logging/core.scm - Core logging functions
(define-module (utils logging core)
#:use-module (utils logging state)
#:use-module (utils logging output)
#:export (log-with-color
log-debug
log-info
log-warn
log-error
log-success))
;; Impure function: Core logging with color and level checking
(define (log-with-color level color prefix message . args)
"Log message with color if level is appropriate"
(when (should-log? level)
(log-to-port (current-error-port) level color prefix message args)))
;; Specific logging functions - each does one thing well
(define (log-debug message . args)
"Log debug message"
(apply log-with-color 'debug 'cyan "DEBUG" message args))
(define (log-info message . args)
"Log info message"
(apply log-with-color 'info 'blue "INFO " message args))
(define (log-warn message . args)
"Log warning message"
(apply log-with-color 'warn 'yellow "WARN " message args))
(define (log-error message . args)
"Log error message"
(apply log-with-color 'error 'red "ERROR" message args))
(define (log-success message . args)
"Log success message"
(apply log-with-color 'info 'green "SUCCESS" message args))