From a313dacae44308761484d7b226d5383ebf311be1 Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Tue, 30 Oct 2018 12:07:32 -0700 Subject: [PATCH] update with log --- pollen/cache.rkt | 2 +- pollen/private/command.rkt | 31 +++++++++++++++--------- pollen/private/preheat-cache.rkt | 2 +- pollen/private/project-server-routes.rkt | 2 +- pollen/private/project-server.rkt | 12 ++++----- pollen/render.rkt | 4 +-- pollen/unstable/pygments.rkt | 2 +- 7 files changed, 31 insertions(+), 24 deletions(-) diff --git a/pollen/cache.rkt b/pollen/cache.rkt index ceaa582..cf9d6d2 100644 --- a/pollen/cache.rkt +++ b/pollen/cache.rkt @@ -3,7 +3,7 @@ racket/list sugar/define "private/cache-utils.rkt" - "private/debug.rkt" + "private/log.rkt" "setup.rkt") ;; The cache is a hash with paths as keys. diff --git a/pollen/private/command.rkt b/pollen/private/command.rkt index 01f76c7..1a00002 100644 --- a/pollen/private/command.rkt +++ b/pollen/private/command.rkt @@ -8,6 +8,7 @@ racket/match sugar/coerce "file-utils.rkt" + "log.rkt" "../setup.rkt" "../render.rkt" "../pagetree.rkt") @@ -30,17 +31,23 @@ (very-nice-path (car args))))) (define (dispatch command-name) - (case command-name - [("test" "xyzzy") (handle-test)] - [(#f "help") (handle-help)] - [("start") (handle-start)] ; parses its own args - ;; "second" arg is actually third in command line args, so use cddr not cdr - [("render") (handle-render)] ; render parses its own args from current-command-line-arguments - [("version") (handle-version)] - [("reset") (handle-reset (get-first-arg-or-current-dir))] - [("setup") (handle-setup (get-first-arg-or-current-dir))] - [("clone" "publish") (handle-publish)] - [else (handle-unknown command-name)])) + (with-logging-to-port + (current-error-port) + (λ () + (case command-name + [("test" "xyzzy") (handle-test)] + [(#f "help") (handle-help)] + [("start") (handle-start)] ; parses its own args + ;; "second" arg is actually third in command line args, so use cddr not cdr + [("render") (handle-render)] ; render parses its own args from current-command-line-arguments + [("version") (handle-version)] + [("reset") (handle-reset (get-first-arg-or-current-dir))] + [("setup") (handle-setup (get-first-arg-or-current-dir))] + [("clone" "publish") (handle-publish)] + [else (handle-unknown command-name)])) + #:logger pollen-logger + 'info + 'pollen)) (define (very-nice-path x) (path->complete-path (simplify-path (cleanse-path (->path x))))) @@ -145,7 +152,7 @@ version print the version" (current-server-port) (make-publish-di (parameterize ([current-project-root dir] [current-server-port (or http-port (setup:project-server-port))] [current-server-listen-ip (and localhost-wanted "127.0.0.1")]) - (displayln "Starting project server ...") + (message "starting project server ...") ((dynamic-require 'pollen/private/project-server 'start-server) (format "/~a" (setup:main-pagetree dir)) launch-wanted))) (define (make-publish-dir-name [project-root (current-directory)] [arg-command-name #f]) diff --git a/pollen/private/preheat-cache.rkt b/pollen/private/preheat-cache.rkt index e486d60..aac1497 100644 --- a/pollen/private/preheat-cache.rkt +++ b/pollen/private/preheat-cache.rkt @@ -6,7 +6,7 @@ sugar/list "file-utils.rkt" "cache-utils.rkt" - "debug.rkt") + "log.rkt") (provide preheat-cache) (define (path-cached? path) diff --git a/pollen/private/project-server-routes.rkt b/pollen/private/project-server-routes.rkt index 393de92..7b09765 100644 --- a/pollen/private/project-server-routes.rkt +++ b/pollen/private/project-server-routes.rkt @@ -22,7 +22,7 @@ sugar/unstable/container txexpr/base "file-utils.rkt" - "debug.rkt" + "log.rkt" "../pagetree.rkt" "../cache.rkt") diff --git a/pollen/private/project-server.rkt b/pollen/private/project-server.rkt index 722f9e1..74f3337 100755 --- a/pollen/private/project-server.rkt +++ b/pollen/private/project-server.rkt @@ -3,7 +3,7 @@ web-server/servlet-env web-server/dispatch "project-server-routes.rkt" - "debug.rkt" + "log.rkt" "../setup.rkt" "../file.rkt" "../cache.rkt" @@ -20,13 +20,13 @@ [((string-arg) ... "out" (string-arg) ...) route-out] [else route-default])) - (message (format "Welcome to Pollen ~a" pollen:version) (format "(Racket ~a)" (version))) - (message (format "Project root is ~a" (current-project-root))) + (message (format "welcome to Pollen ~a (Racket ~a)" pollen:version (version))) + (message (format "project root is ~a" (current-project-root))) (define server-name (format "http://localhost:~a" (current-server-port))) - (message (format "Project server is ~a" server-name) "(Ctrl+C to exit)") - (message (format "Project dashboard is ~a/~a" server-name (setup:main-pagetree))) - (message "Ready to rock") + (message (format "project server is ~a (Ctrl+C to exit)" server-name)) + (message (format "project dashboard is ~a/~a" server-name (setup:main-pagetree))) + (message "ready to rock") (parameterize ([error-print-width 1000]) (serve/servlet pollen-servlet diff --git a/pollen/render.rkt b/pollen/render.rkt index ca35f69..2f83615 100644 --- a/pollen/render.rkt +++ b/pollen/render.rkt @@ -8,7 +8,7 @@ sugar/coerce "private/file-utils.rkt" "cache.rkt" - "private/debug.rkt" + "private/log.rkt" "private/project.rkt" "private/cache-utils.rkt" "pagetree.rkt" @@ -215,7 +215,7 @@ (require (for-syntax racket/base) pollen/private/include-template pollen/cache - pollen/private/debug + pollen/private/log pollen/pagetree pollen/core) DIRECTORY-REQUIRE-FILES diff --git a/pollen/unstable/pygments.rkt b/pollen/unstable/pygments.rkt index 68fc3c2..6685b72 100644 --- a/pollen/unstable/pygments.rkt +++ b/pollen/unstable/pygments.rkt @@ -10,7 +10,7 @@ rackjure/str xml (only-in html read-html-as-xml) - "../private/debug.rkt" + "../private/log.rkt" "../private/splice.rkt") (provide highlight make-highlight-css)