File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change 41
41
import command
42
42
from command import Command
43
43
import logging
44
+ from logging .handlers import RotatingFileHandler
44
45
import tempfile
45
46
import commands
46
47
from commands import Commands , CommandsBase
79
80
help = 'path to the Messages binary' )
80
81
parser .add_argument ('-b' , '--batch' , action = 'store_true' ,
81
82
help = 'batch mode - will log into a file' )
83
+ parser .add_argument ('-B' , '--backupcount' , default = 8 ,
84
+ help = 'how many log files to keep around in batch mode' )
82
85
args = parser .parse_args ()
83
86
84
87
if args .debug :
203
206
level = logging .DEBUG if args .debug
204
207
else logging .INFO )
205
208
logger = logging .getLogger (os .path .basename (sys .argv [0 ]))
209
+ handler = RotatingFileHandler (logfile , maxBytes = 0 ,
210
+ backupCount = args .backupcount )
211
+ handler .doRollover ()
212
+ #
213
+ # Technically, adding a handler to the logger is not necessary
214
+ # since log rotation is done above using doRollover() however
215
+ # it is done anyway in case the handler changes to use implicit
216
+ # rotation in the future.
217
+ #
218
+ logger .addHandler (handler )
206
219
207
220
# We want this to be logged to the log file (if any).
208
221
if project_config :
You can’t perform that action at this time.
0 commit comments