From 54a901abd31cf2e2c346c07e7e6195242d84e798 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20Myyr=C3=A4?= Date: Tue, 22 Oct 2024 06:51:48 +0300 Subject: [PATCH] move (rotate|open|close)-log from debug to primitives These functions need to be compiled after the *data-dir* is defined. An easy option is to move them to primitives.lisp where other data-dir related things are defined. --- debug.lisp | 17 ----------------- primitives.lisp | 19 ++++++++++++++++++- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/debug.lisp b/debug.lisp index 906d82f..2323aa5 100644 --- a/debug.lisp +++ b/debug.lisp @@ -68,20 +68,3 @@ do: *standard-output* *redirect-stream* *trace-output* *redirect-stream* *debug-stream* *redirect-stream*)) - -(defun rotate-log () - (let ((log-filename (merge-pathnames "stumpwm.log" *data-dir*)) - (bkp-log-filename (merge-pathnames "stumpwm.log.1" *data-dir*))) - (when (probe-file log-filename) - (rename-file log-filename bkp-log-filename)))) - -(defun open-log () - (rotate-log) - (let ((log-filename (merge-pathnames "stumpwm.log" *data-dir*))) - (setf *debug-stream* (open log-filename :direction :output - :if-exists :supersede - :if-does-not-exist :create)))) -(defun close-log () - (when (boundp '*debug-stream*) - (close *debug-stream*) - (makunbound '*debug-stream*))) diff --git a/primitives.lisp b/primitives.lisp index 20441c2..eae85b6 100644 --- a/primitives.lisp +++ b/primitives.lisp @@ -1566,7 +1566,24 @@ of :error." (ensure-data-dir) (with-open-file (,s ,(merge-pathnames file *data-dir*) ,@keys) - ,@body))) + ,@body))) + +(defun rotate-log () + (let ((log-filename (merge-pathnames "stumpwm.log" *data-dir*)) + (bkp-log-filename (merge-pathnames "stumpwm.log.1" *data-dir*))) + (when (probe-file log-filename) + (rename-file log-filename bkp-log-filename)))) + +(defun open-log () + (rotate-log) + (let ((log-filename (merge-pathnames "stumpwm.log" *data-dir*))) + (setf *debug-stream* (open log-filename :direction :output + :if-exists :supersede + :if-does-not-exist :create)))) +(defun close-log () + (when (boundp '*debug-stream*) + (close *debug-stream*) + (makunbound '*debug-stream*))) (defmacro move-to-head (list elt) "Move the specified element in in LIST to the head of the list."