logging.scm 961 B

1234567891011121314151617181920212223242526272829303132333435
  1. (library (logging)
  2. (export debug info warning error)
  3. (import (except (rnrs base) let-values error)
  4. (only (guile)
  5. ;; lambda forms
  6. lambda* λ
  7. ;; errors
  8. error
  9. ;; conditionals
  10. when
  11. ;; output
  12. display
  13. ;; ports
  14. current-output-port
  15. ;; strings
  16. string-join
  17. simple-format)))
  18. (define displayln
  19. (lambda* (#:key (output-port (current-output-port)) (verbose #t) . msgs)
  20. (when verbose
  21. (display (string-append
  22. (string-join
  23. (map (lambda (msg) (simple-format #f "~a" msg)) msgs)
  24. " ") "\n")
  25. output-port))))
  26. ;; Currently all logging procedures are merely aliases for displayln.
  27. (define debug displayln)
  28. (define info displayln)
  29. (define warning displayln)
  30. (define error displayln)