PSF: Stabilizing workspace after crash. Valid kernel/skill fixes.
This commit is contained in:
17
projects/org-skill-log-aggregator/src/log-aggregator.lisp
Normal file
17
projects/org-skill-log-aggregator/src/log-aggregator.lisp
Normal file
@@ -0,0 +1,17 @@
|
||||
(defun log-scan (&optional (lines 100))
|
||||
"Reads the last LINES lines of the system log file."
|
||||
(let ((log-file (merge-pathnames "logs/agent.log" (uiop:getenv "SYSTEM_DIR"))))
|
||||
(if (uiop:file-exists-p log-file)
|
||||
(uiop:run-program `("tail" "-n" ,(write-to-string lines) ,(namestring log-file)) :output :string)
|
||||
"Log file not found.")))
|
||||
|
||||
(defun log-summarize (logs)
|
||||
"Symbolic summary of LOGS focusing on errors and warnings."
|
||||
(let ((lines (uiop:split-string logs :separator '(#\Newline)))
|
||||
(errors 0)
|
||||
(warnings 0))
|
||||
(dolist (line lines)
|
||||
(cond
|
||||
((cl-ppcre:scan "ERROR" line) (incf errors))
|
||||
((cl-ppcre:scan "WARN" line) (incf warnings))))
|
||||
(format nil "Log Summary: ~a errors, ~a warnings found in scan." errors warnings)))
|
||||
Reference in New Issue
Block a user