diff options
author | Random Hacker <random_hacker@xapek.org> | 2012-03-06 15:43:32 +0100 |
---|---|---|
committer | Random Hacker <random_hacker@xapek.org> | 2012-03-06 15:43:32 +0100 |
commit | b79a5a8ab011e8b4ee3a9adb3b1085a6acd0f482 (patch) | |
tree | 74c41ae68b1601dc0aeadfdefd64fed5f752466d /ebus-racket/inserter.rkt | |
parent | 86c167acc082328cae11ae5f845d41967689e184 (diff) | |
download | ebus-alt-b79a5a8ab011e8b4ee3a9adb3b1085a6acd0f482.tar.gz ebus-alt-b79a5a8ab011e8b4ee3a9adb3b1085a6acd0f482.zip |
ebus-racket: set db-default loglevel=warning; add exception handler in inserter
Diffstat (limited to 'ebus-racket/inserter.rkt')
-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) |