provide util macros lgd lgi as shortcuts for displaying variable values

This commit is contained in:
Helmut Merz 2024-07-31 20:05:19 +02:00
parent 5a75c10d74
commit b09319916c
4 changed files with 24 additions and 12 deletions

View file

@ -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))))

View file

@ -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)

View file

@ -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)
))

View file

@ -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)