Add a macro strcat for more readability of (concatenate 'string &body)

Use ~/.reed-alert/states instead of $PWD/states/ for saving states
This commit is contained in:
Solene Rapenne 2018-10-21 21:38:46 +02:00
parent 0657e70c77
commit 64185e6f15
1 changed files with 8 additions and 3 deletions

View File

@ -2,7 +2,8 @@
(defparameter *tries* 3)
(defparameter *alerts* '())
(ensure-directories-exist "states/")
(defparameter *states-dir* "~/.reed-alert/states/")
(ensure-directories-exist *states-dir*)
(defun color(num1 num2)
(format nil "~a[~a;~am" #\Escape num1 num2))
@ -57,7 +58,11 @@
`(progn
(defparameter ,name ',name)
(push (list ',name ,string)
*alerts*)))
*alerts*)))
(defmacro strcat(&body body)
`(progn
(concatenate 'string ,@body)))
(defun trigger-alert(level function params result state)
(let* ((notifier-command (assoc level *alerts*))
@ -91,7 +96,7 @@
(let* ((hash (fnv-hash (format nil "~{~a~}" (remove-if #'symbolp params))))
(result (funcall fonction params))
(filename (format nil "~a-~a-~a" level fonction hash))
(filepath (format nil "states/~a" filename)))
(filepath (format nil "~a/~a" *states-dir* filename)))
;; we open the file to read the number of tries
;; if no fail then we have 0 try