Rotate auto.log to auto_<timestamp>.log when it excedes settings logsize

This commit is contained in:
Bob Buxton 2020-07-26 17:23:21 +01:00 committed by HummyPkg
parent 1994d99294
commit c3d360fa63

View File

@ -5,12 +5,13 @@ set ::auto::logprefix ""
set ::auto::loglevel 1
proc ::auto::loginit {} {
variable settings
set logsize [$settings logsize]
# Rotate log file if large enough.
if {[file exists $::auto::logfile] &&
[file size $::auto::logfile] > 2097152} {
file copy -force $::auto::logfile "/mod/tmp/auto_old.log"
file delete $::auto::logfile
[file size $::auto::logfile] > $logsize} {
set tstamp [clock format [clock seconds] -format {%Y%m%d%H%M%S}]
file rename -force $::auto::logfile "/mod/tmp/auto.$tstamp.log"
}
# Open log file