Skip to content

Instantly share code, notes, and snippets.

@borkdude
Last active April 27, 2021 20:23
Show Gist options
  • Save borkdude/c97da85da67c7bcc5671765aef5a89ad to your computer and use it in GitHub Desktop.
Save borkdude/c97da85da67c7bcc5671765aef5a89ad to your computer and use it in GitHub Desktop.
Simple logger that works in bb
(ns logger)
(defmacro log [& msgs]
(let [m (meta &form)
_ns (ns-name *ns*) ;; can also be used for logging
file *file*]
`(binding [*out* *err*] ;; or bind to (io/writer log-file)
(println (str ~file ":"
~(:line m) ":"
~(:column m))
~@msgs))))
(ns bar (:require logger))
(logger/log "what goes on here")
;; <snip>/logger.clj:15:1 what goes on here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment