provide util macros lgd lgi as shortcuts for displaying variable values
This commit is contained in:
		
							parent
							
								
									5a75c10d74
								
							
						
					
					
						commit
						b09319916c
					
				
					 4 changed files with 24 additions and 12 deletions
				
			
		| 
						 | 
					@ -67,7 +67,7 @@
 | 
				
			||||||
          (update track new-data))))))
 | 
					          (update track new-data))))))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
(defun query-one (cont crit &key (order-by '(:trackid)))
 | 
					(defun query-one (cont crit &key (order-by '(:trackid)))
 | 
				
			||||||
  ;(log:info "crit: ~s" crit)
 | 
					  (util:lgd crit)
 | 
				
			||||||
  (let* ((tr (make-item cont))
 | 
					  (let* ((tr (make-item cont))
 | 
				
			||||||
         (st (storage cont))
 | 
					         (st (storage cont))
 | 
				
			||||||
         (table (storage:qualified-table-name st (table-name cont)))
 | 
					         (table (storage:qualified-table-name st (table-name cont)))
 | 
				
			||||||
| 
						 | 
					@ -107,14 +107,15 @@
 | 
				
			||||||
  (let (crit)
 | 
					  (let (crit)
 | 
				
			||||||
    (dolist (spec specs)
 | 
					    (dolist (spec specs)
 | 
				
			||||||
      (destructuring-bind (f v &optional op) spec
 | 
					      (destructuring-bind (f v &optional op) spec
 | 
				
			||||||
        (when v
 | 
					        (unless v
 | 
				
			||||||
 | 
					          (setf v ""))
 | 
				
			||||||
        (when (eq f :time-stamp)
 | 
					        (when (eq f :time-stamp)
 | 
				
			||||||
          (setf f :timestamp))
 | 
					          (setf f :timestamp))
 | 
				
			||||||
        (unless op
 | 
					        (unless op
 | 
				
			||||||
          (setf op (if (eq f :timestamp) :>= :=)))
 | 
					          (setf op (if (eq f :timestamp) :>= :=)))
 | 
				
			||||||
        (when (symbolp v)
 | 
					        (when (symbolp v)
 | 
				
			||||||
          (setf v (string-downcase v)))
 | 
					          (setf v (string-downcase v)))
 | 
				
			||||||
          (push (list op f v) crit))))
 | 
					        (push (list op f v) crit)))
 | 
				
			||||||
    (if (cdr crit)
 | 
					    (if (cdr crit)
 | 
				
			||||||
      (cons :and crit)
 | 
					      (cons :and crit)
 | 
				
			||||||
      (car crit))))
 | 
					      (car crit))))
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -6,7 +6,7 @@
 | 
				
			||||||
(config:root :env-keys '(:db-name))
 | 
					(config:root :env-keys '(:db-name))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
(config:add :logger  :class 'logging:config
 | 
					(config:add :logger  :class 'logging:config
 | 
				
			||||||
            :loglevel :info
 | 
					            :loglevel :debug
 | 
				
			||||||
            :logfile (t:test-path "scopes-test.log" "log")
 | 
					            :logfile (t:test-path "scopes-test.log" "log")
 | 
				
			||||||
            :console nil)
 | 
					            :console nil)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -12,6 +12,7 @@
 | 
				
			||||||
                    (:shape :scopes/shape)
 | 
					                    (:shape :scopes/shape)
 | 
				
			||||||
                    (:storage :scopes/storage)
 | 
					                    (:storage :scopes/storage)
 | 
				
			||||||
                    (:tracking :scopes/storage/tracking) 
 | 
					                    (:tracking :scopes/storage/tracking) 
 | 
				
			||||||
 | 
					                    (:util :scopes/util)
 | 
				
			||||||
                    (:t :scopes/testing)
 | 
					                    (:t :scopes/testing)
 | 
				
			||||||
                    (:alx :alexandria))
 | 
					                    (:alx :alexandria))
 | 
				
			||||||
  (:export #:run #:run-all #:run-postgres #:run-sqlite)
 | 
					  (:export #:run #:run-all #:run-postgres #:run-sqlite)
 | 
				
			||||||
| 
						 | 
					@ -72,5 +73,6 @@
 | 
				
			||||||
    (== (shape:head pm2) '(:test :data :field nil))
 | 
					    (== (shape:head pm2) '(:test :data :field nil))
 | 
				
			||||||
    (== (getf (shape:data pm2) :info) "test data")
 | 
					    (== (getf (shape:data pm2) :info) "test data")
 | 
				
			||||||
    (setf pm3 (tracking:query-last cont '(:domain :test)))
 | 
					    (setf pm3 (tracking:query-last cont '(:domain :test)))
 | 
				
			||||||
    (log:info "pm3: ~s" pm3)
 | 
					    (util:lgi pm3)
 | 
				
			||||||
 | 
					    ;(log:info "pm3: ~s" pm3)
 | 
				
			||||||
    ))
 | 
					    ))
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										11
									
								
								util.lisp
									
										
									
									
									
								
							
							
						
						
									
										11
									
								
								util.lisp
									
										
									
									
									
								
							| 
						 | 
					@ -2,13 +2,22 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
(defpackage :scopes/util
 | 
					(defpackage :scopes/util
 | 
				
			||||||
  (:use :common-lisp)
 | 
					  (:use :common-lisp)
 | 
				
			||||||
  (:export #:rtrim #:loop-plist
 | 
					  (:export #:lg #:lgd #:lgi
 | 
				
			||||||
 | 
					           #:rtrim #:loop-plist
 | 
				
			||||||
           #:flatten-str #:to-keyword #:keyword-to-string #:to-string
 | 
					           #:flatten-str #:to-keyword #:keyword-to-string #:to-string
 | 
				
			||||||
           #:absolute-dir #:check-dir #:ensure-dir #:home-path #:path-from-string
 | 
					           #:absolute-dir #:check-dir #:ensure-dir #:home-path #:path-from-string
 | 
				
			||||||
           #:relative-path #:runtime-path #:system-path))
 | 
					           #:relative-path #:runtime-path #:system-path))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
(in-package :scopes/util)
 | 
					(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
 | 
					;;;; lists and loops
 | 
				
			||||||
 | 
					
 | 
				
			||||||
(defun rtrim (lst)
 | 
					(defun rtrim (lst)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue