commit a44828d0acf4d6a92b6d15cc5c802082be08c561
parent 17881397605375cf6f646a294d22706f922148a6
Author: ChanderG <[email protected]>
Date: Thu, 27 Nov 2025 16:19:41 +0530
add logging based on vom lib
very simple logging
Diffstat:
3 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/grep.asd b/grep.asd
@@ -2,10 +2,12 @@
:version "0.0.1"
:author "Chander Govindarajan"
:components ((:file "package")
+ (:file "log")
(:file "grep"))
:depends-on (:uiop
:filesystem-utils
- :pathname-utils)
+ :pathname-utils
+ :vom)
:build-operation "program-op"
:build-pathname "cl-grep"
:entry-point "cl-grep:main")
diff --git a/grep.lisp b/grep.lisp
@@ -1,22 +1,22 @@
-(in-package cl-grep)
+(in-package :cl-grep)
(defun queue-file (file)
- (format t "Visiting file: ~a~%" file)
+ (lo "Visiting file: ~a" file)
(let* ((name (pu:file-name file))
(blacklist (list #\~ #\#))
(lc (char name (- (length name) 1))))
(when (member lc blacklist)
- (format t "Skipping ignorable file: ~a~%" file)
+ (lo "Skipping ignorable file: ~a" file)
(return-from queue-file nil))))
;; do the actual thing here
(defun fs-walker (dir)
- (format t "Visiting dir: ~a~%" dir)
+ (lo "Visiting dir: ~a" dir)
;; check if we should visit this dir
(let ((dirname (pu:directory-name dir))
(blacklist (list ".git" ".venv")))
(when (member dirname blacklist :test #'equalp)
- (format t "Skipping dir: ~a~%" dir)
+ (lo "Skipping dir: ~a" dir)
(return-from fs-walker nil)))
;; process files in this dir
(fsu:map-directory #'queue-file dir
@@ -30,6 +30,7 @@
(fs-walker dir))
(defun main ()
+ (log-setup)
(let* ((args (uiop:command-line-arguments))
(nargs (length args)))
(when (or (eq nargs 0) (> nargs 2))
diff --git a/log.lisp b/log.lisp
@@ -0,0 +1,10 @@
+(in-package :cl-grep)
+
+(defun log-setup ()
+ (vom:config t :info)
+ (setf vom:*log-stream* (open "./cl-grep.log" :direction :output
+ :if-exists :overwrite
+ :if-does-not-exist :create)))
+
+(defmacro lo (&rest args)
+ `(vom:info ,@args))