mirror of
https://github.com/brmlab/brmdoor_libnfc.git
synced 2025-06-07 16:14:01 +02:00
Change file handler to rotating file handler, 1 MB max, 5 files
This commit is contained in:
parent
3cf3d182cf
commit
fda6f26db4
1 changed files with 10 additions and 5 deletions
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import logging
|
import logging
|
||||||
|
import logging.handlers
|
||||||
import time
|
import time
|
||||||
import ConfigParser
|
import ConfigParser
|
||||||
import threading
|
import threading
|
||||||
|
@ -352,13 +353,17 @@ if __name__ == "__main__":
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
config = BrmdoorConfig(sys.argv[1])
|
config = BrmdoorConfig(sys.argv[1])
|
||||||
|
fmt="%(asctime)s %(levelname)s %(message)s [%(pathname)s:%(lineno)d]"
|
||||||
|
|
||||||
if config.logFile == "-":
|
if config.logFile == "-":
|
||||||
logging.basicConfig(stream=sys.stderr, level=config.logLevel,
|
logging.basicConfig(stream=sys.stderr, level=config.logLevel, format=fmt)
|
||||||
format="%(asctime)s %(levelname)s %(message)s [%(pathname)s:%(lineno)d]")
|
|
||||||
else:
|
else:
|
||||||
logging.basicConfig(filename=config.logFile, level=config.logLevel,
|
handler = logging.handlers.RotatingFileHandler(filename=config.logFile, maxBytes=1000000, backupCount=5)
|
||||||
format="%(asctime)s %(levelname)s %(message)s [%(pathname)s:%(lineno)d]")
|
handler.setLevel(config.logLevel)
|
||||||
|
handler.setFormatter(logging.Formatter(fmt))
|
||||||
|
mainLogger = logging.getLogger('')
|
||||||
|
mainLogger.addHandler(handler)
|
||||||
|
mainLogger.setLevel(config.logLevel)
|
||||||
|
|
||||||
ircMsgQueue = Queue.Queue()
|
ircMsgQueue = Queue.Queue()
|
||||||
ircThread = None
|
ircThread = None
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue