debug.scm
(module debug mzscheme
        (require (lib "date.ss"))
        (provide hlog
                 debug)

        (define LOGFH         (open-output-file (if (eq? (getenv "HWIKI_LOGS") #f)
                                                    "hwiki.log"
                                                    (path->string (build-path (getenv "HWIKI_LOGS") "hwiki.log")))
                                                'replace))
        
        (define DEBUG         (not (eq? (getenv "HWIKI_DEBUG") #f)))

        (define (hlog . args)
          (display (format "log  :~a:~s~%" (date->string (seconds->date (current-seconds)) #t) args) LOGFH)
          (flush-output LOGFH))

        (define (debug . args)
          (if DEBUG
              (begin
                (display (format "debug:~a:~s~%" (date->string (seconds->date (current-seconds)) #t) args) LOGFH)
                (flush-output LOGFH))))

        (date-display-format 'iso-8601)

        )