clean and stable file logging; thanks to python-list for that

This commit is contained in:
Johannes Findeisen 2013-10-27 15:37:04 +01:00
commit f9917614c9

View file

@ -20,7 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
""" """
__version__ = "0.11.1" __version__ = "0.11.2"
__default_config__ = "./examples/minimal.json" __default_config__ = "./examples/minimal.json"
import argparse import argparse
@ -79,13 +79,14 @@ def main():
if not path.exists(path.dirname(logfile)): if not path.exists(path.dirname(logfile)):
os.makedirs(path.dirname(logfile)) os.makedirs(path.dirname(logfile))
#logger.propagate = False root_logger = logging.getLogger()
logging.basicConfig(level=args.loglevel)
#file_handler = logging.handlers.RotatingFileHandler(args.logfile, maxBytes=10485760, backupCount=4) formatter = logging.Formatter(logging.BASIC_FORMAT)
#file_formatter = logging.Formatter('%(asctime)s %(pathname)s %(module)s %(funcName)s %(lineno)d [%(levelname)s]: %(message)s') handler = logging.handlers.RotatingFileHandler(args.logfile, maxBytes=10485760, backupCount=4)
#file_handler.setFormatter(file_formatter) handler.setFormatter(formatter)
#file_handler.setLevel(level=args.loglevel)
#logger.addHandler(file_handler) root_logger.addHandler(handler)
root_logger.setLevel(args.loglevel)
configParser = FullConfigParser() configParser = FullConfigParser()
linConf, core = configParser.parse_config(args.config) linConf, core = configParser.parse_config(args.config)