Application logging library
Quick look at features:
-
Optionally Time-stamped formatted log entries 2021-10-27 13:55:36.423013 xlog: end of log-file 2021-10-27_dispatch-rescancanm.log
-
Log files can be appended to or superseded
-
Log directory can be specified
(with-open-log-file (<filespec> :dir "<log file directory>") ... )
-
Log file extension can be specified
(with-open-log-file (<filespec> :extension "out") ... )
-
Log entry can be also pushed to standard out Usual output is (xlogf "" ) ; in the manner of (format ...) Copy to standard output is
(xlogft "<format string>" ... _)
-
Alert file support for status reporting Set alert file name:
(set-alert-file-name "<name of alert file>").
(xalert "simple string")
; opens alert file, writes values, closes alert file(xlalertf "format string" <val1> ... )
-
Support for date-stamped file names with options for hour,minute,second resulution, hour resolution, date only, or no date.
(with-open-log-file ("filespec" :dates (t :hms :hour :dates)
-
Log files can be nested. The
with-open-log-file
macro wraps code in the manner ofwith-open-file
. If you nest the calls, upon closing the nested open, the original one resumes. This can ease reading detail processes within a global process.
Log files can be nested. A second consecutive log file opening will push the existing log file and name onto a stack.
If show-log-file-name
is set, the name of the new log file will be written to the existing one. Once the new log
file is opened, the name of the previously opened log file will be logged.
The purpose of the alert file is to provide a short status for other programs to inspect without analyzing the log file.
set-alert-file-name (name)
xalertf(fmt vars)
Write an alert to the alert file and to the log file.
Functions:
(xlog-version)
For an example string 2024-05-30 00:00:01.593760
, answer multi-value seconds and milliseconds.
unpack-utc-with-hyphens(utc-string)
2024-05-30 00:00:01.593760
calc-elapsed-time (tim)
formatted-current-time-micro (str)
formatted-file-time (filename)
formatted-current-time ()
dates-ymd (datecmd)
For values of datecmd
:hms
Format the date with month, day, year, hours, minutes, and seconds.:hour
Format the date with month, day, year, and hourt
Format the date year, month, day
debugc (val stmt)
If val
is less than or equal to *debug-level*
, evaluate stmt
.
xlog(str)
Write a time-stamped line to the log file. All log entries come through this function. Items written the log file
end with a new line. Lines are forced to begin at the first position by the use of fresh-line
.
xlognt
As xlog
, but without time prefix.
xlogfin
xlogf (fmt vars)
xlogff(fmt vars)
xlogft(fmt vars)
xlogntf(fmt vars)
xlogntft