Rotating log file with retention
This commit is contained in:
@@ -7,11 +7,13 @@
|
||||
data/queue
|
||||
"private/loghash.rkt"
|
||||
"private/store.rkt"
|
||||
"private/rotating-file.rkt"
|
||||
)
|
||||
|
||||
(provide sl-def-log
|
||||
sl-log-to
|
||||
sl-log-to-file
|
||||
sl-log-to-rotating-file
|
||||
sl-log-to-display
|
||||
sl-log-to-store
|
||||
sl-log-to-file&display
|
||||
@@ -211,6 +213,24 @@
|
||||
(dbg-simple-log "log-to-file enabled with file ~a" filename)
|
||||
)
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; goal : Enable daily rotating file logging.
|
||||
; pre : filename is a path string and retention-days is a positive integer.
|
||||
; post : The current day is logged as plain text. Older retained days are
|
||||
; stored as <filename>.YYYY-MM-DD.gz.
|
||||
; result : void
|
||||
; internals : retention-days includes the current, uncompressed day.
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
(define (sl-log-to-rotating-file filename [retention-days 7])
|
||||
(unless (exact-positive-integer? retention-days)
|
||||
(raise-argument-error 'sl-log-to-rotating-file
|
||||
"exact-positive-integer?"
|
||||
retention-days))
|
||||
(sl-log-to file (make-rotating-log-callback filename retention-days))
|
||||
(dbg-simple-log "rotating log-to-file enabled with file ~a and retention ~a days"
|
||||
filename retention-days)
|
||||
)
|
||||
|
||||
(define-syntax def-log2
|
||||
(syntax-rules ()
|
||||
((_ id parent receiver log-callbacks dbgn infon warnn errn fataln syncn)
|
||||
|
||||
Reference in New Issue
Block a user