From 99c6eb21eb7ff9a072b87d9d64324871ea7201f1 Mon Sep 17 00:00:00 2001 From: Yves Fischer Date: Sat, 26 Jul 2014 20:15:03 +0200 Subject: fix logging, re-enable dumper layer7 output --- ebus-racket/ebus/layer2.rkt | 6 ++++-- ebus-racket/ebus/layer7.rkt | 10 +++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) (limited to 'ebus-racket/ebus') diff --git a/ebus-racket/ebus/layer2.rkt b/ebus-racket/ebus/layer2.rkt index 3309c16..192f7f5 100644 --- a/ebus-racket/ebus/layer2.rkt +++ b/ebus-racket/ebus/layer2.rkt @@ -3,6 +3,8 @@ (planet bzlib/parseq:1:3)) (define logger (make-logger 'ebus-layer2 (current-logger))) +(current-logger logger) + ;; Ebus SYN (define ebus-const-syn #xaa) ;; Ebus Escape-Sequence Start @@ -83,7 +85,7 @@ (define syn ((make-reader ebus-sync #:sof? #f #:eof? #f) input-port)) (define paket ((make-reader parse-ebus-paket #:sof? #f #:eof? #f) input-port)) (cond ((not (false? syn)) - (log-message logger 'debug (format "drop ~s x SYN (~s)" syn ebus-const-syn) #t))) + (log-debug "drop ~s x SYN (~s)" syn ebus-const-syn))) (cond ((not (false? paket)) paket) ((eof-object? (peek-byte input-port)) @@ -91,7 +93,7 @@ (else ;; skip one byte (let ([byte (read-byte input-port)]) - (log-message logger 'debug (format "drop ~s 0x~x" byte byte) #t)) + (log-debug "drop ~s 0x~x" byte byte)) (read-ebus input-port)))) (provide diff --git a/ebus-racket/ebus/layer7.rkt b/ebus-racket/ebus/layer7.rkt index c7fb228..60f8bbc 100644 --- a/ebus-racket/ebus/layer7.rkt +++ b/ebus-racket/ebus/layer7.rkt @@ -7,6 +7,7 @@ "layer2.rkt") (define logger (make-logger 'ebus-layer7 (current-logger))) +(current-logger logger) (define definition (parameterize ([collapse-whitespace #t] @@ -16,6 +17,7 @@ (define (paket ebus-paket) (define primaryCommand (number->string (layer2-ebus-paket-primaryCommand ebus-paket))) (define secondaryCommand (number->string (layer2-ebus-paket-secondaryCommand ebus-paket))) + (log-debug "Lookup paket primaryCommand=~a secondaryCommand=~a" primaryCommand secondaryCommand) (xexpr-path-first (list 'packets 'packet (list 'primary primaryCommand) (list 'secondary secondaryCommand)) definition)) @@ -44,8 +46,10 @@ (define payload (layer2-ebus-paket-payload ebus-paket)) (for/list ([decoder decoders]) (decoder payload))) - (else (void (log-message logger 'warning - (format "Unknown Paket from source ~s: ~s" (layer2-ebus-paket-source ebus-paket) ebus-paket) #t))))) + (else (void (log-info "Unknown Paket from source ~s(~s): ~s" + (layer2-ebus-paket-source ebus-paket) + source-device-name + ebus-paket))))) (define (create-decoder paket-id field) @@ -53,7 +57,7 @@ (define name (string-append paket-id "." (xexpr-path-first '((name)) field))) (define offset (string->number (xexpr-path-first '((offset)) field))) (define decoder (hash-ref decoder-table type #f)) - (cond ((false? decoder) (void (log-message logger 'warning (format "No decoder for type ~s" type) #t))) + (cond ((false? decoder) (void (log-warning "No decoder for type ~s" type))) (else (curry (car decoder) name field offset)))) (define decoder-table -- cgit v1.2.1