summaryrefslogtreecommitdiff
path: root/ebus-racket/inserter.rkt
diff options
context:
space:
mode:
Diffstat (limited to 'ebus-racket/inserter.rkt')
-rwxr-xr-xebus-racket/inserter.rkt23
1 files changed, 12 insertions, 11 deletions
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)))