Skip to content

Instantly share code, notes, and snippets.

@dyoo
Created February 28, 2013 21:29
Show Gist options
  • Select an option

  • Save dyoo/5060281 to your computer and use it in GitHub Desktop.

Select an option

Save dyoo/5060281 to your computer and use it in GitHub Desktop.
#lang racket
(require racket/stxparam)
(define verbosity-level (make-parameter 0))
(define-syntax (log stx)
(syntax-case stx ()
([_ num msg ...]
#`(when (>= (verbosity-level) num)
(apply printf (list msg ...))))))
(parameterize
([verbosity-level 1 ;;0
])
(log 1 "test at runtime\n"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment