diff options
-rwxr-xr-x | ebus-racket/inserter.rkt | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/ebus-racket/inserter.rkt b/ebus-racket/inserter.rkt index bd23e04..ab90911 100755 --- a/ebus-racket/inserter.rkt +++ b/ebus-racket/inserter.rkt @@ -13,23 +13,27 @@ (define connect-host? (make-parameter null)) (define connect-port? (make-parameter null)) (define loglevel-layer2? (make-parameter 'info)) -(define loglevel-db? (make-parameter 'info)) +(define loglevel-db? (make-parameter 'warning)) (define insert? (make-parameter #f)) (define (handle-fields fields) (for ([field fields]) (log-message logger 'info (format "Field: ~a" field) #t) (when (insert?) - (apply db-insert-field field)))) + (with-handlers ([exn:fail? (lambda (exn) + (log-message logger 'error (format "Failed to insert ~a: ~a" field exn) #t))]) + (apply db-insert-field field))))) (define (make-ebus-loop7 input-port) (lambda () (let loop () - (let ([fields (layer7-read-ebus (current-input-port))]) - (when (not (or (void? fields) (eof-object? fields))) - (handle-fields fields)) - (when (not (eof-object? fields)) - (loop)))))) + (with-handlers ([exn:fail? (lambda (exn) + (log-message logger 'error (format "Failed to parse paket: ~a" exn) #t))]) + (let ([fields (layer7-read-ebus (current-input-port))]) + (when (not (or (void? fields) (eof-object? fields))) + (handle-fields fields)) + (when (not (eof-object? fields)) + (loop))))))) ;; Start Thread that observe all given log-receivers (define (start-logger-thread receiver1 . receiverN) |