-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug.ss
More file actions
26 lines (21 loc) · 922 Bytes
/
debug.ss
File metadata and controls
26 lines (21 loc) · 922 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#lang scheme/base
(require scheme/match
"private/config.ss")
(provide debug)
(define (observing? topic)
(case topic
[(scope-resolution) (debug-scope-resolution?)]
[(unbound-reference) (debug-unbound-references?)]
[else (error 'debug (format "unknown topic: ~a" topic))]))
(define (debug . args)
(match args
[(list (? symbol? topic) (? string? fmt) rest-args ...)
(when (observing? topic)
(parameterize ([print-struct #t])
(apply fprintf (current-debug-port) (string-append "~a: " fmt "~n") topic rest-args)))]
[(list (? string? fmt) rest-args ...)
(apply fprintf (current-debug-port) (string-append "DEBUG: " fmt "~n") rest-args)]))
; (define (debug topic fmt . args)
; (when (observing? topic)
; (parameterize ([print-struct #t])
; (apply fprintf (current-debug-port) (string-append "~a: " fmt "~n") topic args))))