From 99c6eb21eb7ff9a072b87d9d64324871ea7201f1 Mon Sep 17 00:00:00 2001 From: Yves Fischer Date: Sat, 26 Jul 2014 20:15:03 +0200 Subject: fix logging, re-enable dumper layer7 output --- ebus-racket/inserter.rkt | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'ebus-racket/inserter.rkt') diff --git a/ebus-racket/inserter.rkt b/ebus-racket/inserter.rkt index cd05ad9..90ae258 100755 --- a/ebus-racket/inserter.rkt +++ b/ebus-racket/inserter.rkt @@ -9,6 +9,7 @@ "util/json.rkt") (define logger (make-logger 'ebus-inserter (current-logger))) +(current-logger logger) (define connect-host? (make-parameter null)) (define connect-port? (make-parameter null)) @@ -28,21 +29,21 @@ (string->bytes/utf-8 (format "value=~a&type=~a" value type))))) (define responseJson (string->jsexpr response)) (cond ((eq? (json-null) (hash-ref responseJson 'error)) - (log-message logger 'debug (format "Successful insert: type=~a value=~a" - type value) #t)) - (else (log-message logger 'error (format "Error: type=~a value=~a ERROR:~a" - type value response) #t)))) + (log-debug "Successful insert: type=~a value=~a" + type value)) + (else (log-error "Error: type=~a value=~a ERROR:~a" + type value response)))) (define (handle-packet packet) (for ([field packet]) - (log-message logger 'info (format "Field: ~a" field) #t) + (log-info "Field: ~a" field) (when (insert?) (with-handlers ([exn:fail? (lambda (exn) - (log-message logger 'error (format "Failed to insert ~a: ~a" field exn) #t))] + (log-error "Failed to insert ~a: ~a" field exn))] [exn:fail:read? (lambda (exn) - (log-message logger 'error (format "TCP Read exception ~a" exn) #t))] + (log-error "TCP Read exception ~a" exn))] [exn:fail:network? (lambda (exn) - (log-message logger 'error (format "TCP Exception ~a" exn) #t))]) + (log-error "TCP Exception ~a" exn))]) (apply insert-field field))))) (define-namespace-anchor repl-ns-anchor) @@ -63,9 +64,9 @@ ;; Connect, replacing input with tcp connection (if (or (null? (connect-host?)) (null? (connect-port?))) - (log-message (current-logger) 'info "Using stdin" #t) + (log-info "Using stdin") (let-values ([(cin cout) (tcp-connect (connect-host?) (connect-port?))]) - (log-message logger 'info (format "Connected to ~s ~s ~n" (connect-host?) (connect-port?)) #t) + (log-info "Connected to ~s ~s ~n" (connect-host?) (connect-port?)) (current-input-port cin))) ;; Process Ebus Packets @@ -77,7 +78,7 @@ (define (make-stream port) (stream-cons (with-handlers ([exn:fail? (lambda (exn) - (log-message logger 'error (format "Failed to parse paket: ~a" exn) #t) + (log-error "Failed to parse paket: ~a" exn) (void))]) (layer7-read-ebus port)) (make-stream port))) -- cgit v1.2.1