diff options
Diffstat (limited to 'ebus-racket/inserter.rkt')
-rwxr-xr-x | ebus-racket/inserter.rkt | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/ebus-racket/inserter.rkt b/ebus-racket/inserter.rkt index 90ae258..ab97ecf 100755 --- a/ebus-racket/inserter.rkt +++ b/ebus-racket/inserter.rkt @@ -8,8 +8,7 @@ "util/tcp-repl.rkt" "util/json.rkt") -(define logger (make-logger 'ebus-inserter (current-logger))) -(current-logger logger) +(define-logger inserter) (define connect-host? (make-parameter null)) (define connect-port? (make-parameter null)) @@ -29,21 +28,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-debug "Successful insert: type=~a value=~a" + (log-inserter-debug "Successful insert: type=~a value=~a" type value)) - (else (log-error "Error: type=~a value=~a ERROR:~a" + (else (log-inserter-error "Error: type=~a value=~a ERROR:~a" type value response)))) (define (handle-packet packet) (for ([field packet]) - (log-info "Field: ~a" field) + (log-inserter-info "Field: ~a" field) (when (insert?) (with-handlers ([exn:fail? (lambda (exn) - (log-error "Failed to insert ~a: ~a" field exn))] + (log-inserter-error "Failed to insert ~a: ~a" field exn))] [exn:fail:read? (lambda (exn) - (log-error "TCP Read exception ~a" exn))] + (log-inserter-error "TCP Read exception ~a" exn))] [exn:fail:network? (lambda (exn) - (log-error "TCP Exception ~a" exn))]) + (log-inserter-error "TCP Exception ~a" exn))]) (apply insert-field field))))) (define-namespace-anchor repl-ns-anchor) @@ -64,9 +63,9 @@ ;; Connect, replacing input with tcp connection (if (or (null? (connect-host?)) (null? (connect-port?))) - (log-info "Using stdin") + (log-inserter-info "Using stdin") (let-values ([(cin cout) (tcp-connect (connect-host?) (connect-port?))]) - (log-info "Connected to ~s ~s ~n" (connect-host?) (connect-port?)) + (log-inserter-info "Connected to ~s ~s ~n" (connect-host?) (connect-port?)) (current-input-port cin))) ;; Process Ebus Packets @@ -78,7 +77,7 @@ (define (make-stream port) (stream-cons (with-handlers ([exn:fail? (lambda (exn) - (log-error "Failed to parse paket: ~a" exn) + (log-inserter-error "Failed to parse paket: ~a" exn) (void))]) (layer7-read-ebus port)) (make-stream port))) |