diff --git a/storage/tracking.lisp b/storage/tracking.lisp index 0f50283..db941af 100644 --- a/storage/tracking.lisp +++ b/storage/tracking.lisp @@ -67,7 +67,7 @@ (update track new-data)))))) (defun query-one (cont crit &key (order-by '(:trackid))) - ;(log:info "crit: ~s" crit) + (util:lgd crit) (let* ((tr (make-item cont)) (st (storage cont)) (table (storage:qualified-table-name st (table-name cont))) @@ -107,14 +107,15 @@ (let (crit) (dolist (spec specs) (destructuring-bind (f v &optional op) spec - (when v - (when (eq f :time-stamp) - (setf f :timestamp)) - (unless op - (setf op (if (eq f :timestamp) :>= :=))) - (when (symbolp v) - (setf v (string-downcase v))) - (push (list op f v) crit)))) + (unless v + (setf v "")) + (when (eq f :time-stamp) + (setf f :timestamp)) + (unless op + (setf op (if (eq f :timestamp) :>= :=))) + (when (symbolp v) + (setf v (string-downcase v))) + (push (list op f v) crit))) (if (cdr crit) (cons :and crit) (car crit)))) diff --git a/test/config-sqlite.lisp b/test/config-sqlite.lisp index 356d7e1..8ec1726 100644 --- a/test/config-sqlite.lisp +++ b/test/config-sqlite.lisp @@ -6,7 +6,7 @@ (config:root :env-keys '(:db-name)) (config:add :logger :class 'logging:config - :loglevel :info + :loglevel :debug :logfile (t:test-path "scopes-test.log" "log") :console nil) diff --git a/test/test-storage.lisp b/test/test-storage.lisp index a210294..3fec21b 100644 --- a/test/test-storage.lisp +++ b/test/test-storage.lisp @@ -12,6 +12,7 @@ (:shape :scopes/shape) (:storage :scopes/storage) (:tracking :scopes/storage/tracking) + (:util :scopes/util) (:t :scopes/testing) (:alx :alexandria)) (:export #:run #:run-all #:run-postgres #:run-sqlite) @@ -72,5 +73,6 @@ (== (shape:head pm2) '(:test :data :field nil)) (== (getf (shape:data pm2) :info) "test data") (setf pm3 (tracking:query-last cont '(:domain :test))) - (log:info "pm3: ~s" pm3) + (util:lgi pm3) + ;(log:info "pm3: ~s" pm3) )) diff --git a/util.lisp b/util.lisp index 382f3ed..cd935d5 100644 --- a/util.lisp +++ b/util.lisp @@ -2,13 +2,22 @@ (defpackage :scopes/util (:use :common-lisp) - (:export #:rtrim #:loop-plist + (:export #:lg #:lgd #:lgi + #:rtrim #:loop-plist #:flatten-str #:to-keyword #:keyword-to-string #:to-string #:absolute-dir #:check-dir #:ensure-dir #:home-path #:path-from-string #:relative-path #:runtime-path #:system-path)) (in-package :scopes/util) +(defmacro lg (level &rest vars) + (let ((lm (find-symbol (string level) :log)) + (fm (format nil "~{~a: ~~S ~}" vars))) + `(,lm ,fm ,@vars))) + +(defmacro lgd (&rest vars) `(lg :debug ,@vars)) +(defmacro lgi (&rest vars) `(lg :info ,@vars)) + ;;;; lists and loops (defun rtrim (lst)