From 3c7da220ac8f327dc2fe7fec3a2de203fdc670a0 Mon Sep 17 00:00:00 2001 From: Random Hacker Date: Sun, 4 Mar 2012 22:30:25 +0100 Subject: ebus-racket: inserter.rkt Logging, fix db-insert --- ebus-racket/db.rkt | 2 +- ebus-racket/inserter.rkt | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/ebus-racket/db.rkt b/ebus-racket/db.rkt index 54de8f7..f203c5b 100644 --- a/ebus-racket/db.rkt +++ b/ebus-racket/db.rkt @@ -73,7 +73,7 @@ (format "sensor-id=~a type=~a value-float=~a value-int=~a value-string=~a" sensor-id type value-float value-int value-string)) #t) - (db:query-exec sql-stmt sensor-id type value-float value-int value-string)) + (db:query-exec pgc sql-stmt sensor-id type value-float value-int value-string)) (provide (prefix-out db- logger) diff --git a/ebus-racket/inserter.rkt b/ebus-racket/inserter.rkt index c340019..9aaca78 100755 --- a/ebus-racket/inserter.rkt +++ b/ebus-racket/inserter.rkt @@ -8,6 +8,8 @@ "layer7.rkt" "layer2.rkt") +(define logger (make-logger 'ebus-inserter (current-logger))) + (define connect-host? (make-parameter null)) (define connect-port? (make-parameter null)) (define loglevel-layer2? (make-parameter 'info)) @@ -16,10 +18,9 @@ (define (handle-fields fields) (for ([field fields]) + (log-message logger 'info (format "Field: ~a" field) #t) (when (insert?) - (apply db-insert-field field)) - (when (not (insert?)) - (display (format "Field: ~a~n" field))))) + (apply db-insert-field field)))) (define (read-ebus-loop7 input-port) (let ([fields (layer7-read-ebus (current-input-port))]) @@ -46,7 +47,7 @@ #:once-each [("-c" "--connect") host port "Connect to server " (connect-host? host) - (connect-port? port)] + (connect-port? (string->number port))] ["--debug-layer2" "Log level for Layer 2 Parser" (loglevel-layer2? 'debug)] ["--debug-db" "Log level for DB" @@ -63,7 +64,7 @@ (db-con-server? server)]) ;; Init Logging - (start-logger-thread (make-log-receiver (current-logger) 'info) + (start-logger-thread (make-log-receiver logger 'info) (make-log-receiver db-logger (loglevel-db?)) (make-log-receiver layer2-logger (loglevel-layer2?)) (make-log-receiver layer7-logger 'info)) -- cgit v1.2.1