Commit 85f94aa9 authored by Łukasz Nowak's avatar Łukasz Nowak

Initialise logging support.

parent a5d06e80
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
############################################################################## ##############################################################################
import ConfigParser import ConfigParser
import argparse import argparse
import logging
import os import os
import pkg_resources import pkg_resources
...@@ -40,10 +41,25 @@ def main(*args): ...@@ -40,10 +41,25 @@ def main(*args):
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument("configuration_file", nargs=1, type=argparse.FileType(), parser.add_argument("configuration_file", nargs=1, type=argparse.FileType(),
help="Configuration file.") help="Configuration file.")
parser.add_argument('-c', '--console', action='store_true',
help="Enable console output.")
parser.add_argument('-l', '--logfile', help="Enable output into logfile.")
if args: if args:
parsed_argument = parser.parse_args(list(args)) parsed_argument = parser.parse_args(list(args))
else: else:
parsed_argument = parser.parse_args() parsed_argument = parser.parse_args()
logger = None
if parsed_argument.console or parsed_argument.logfile:
logger = logging.getLogger('erp5testnode')
logger.setLevel(logging.INFO)
if parsed_argument.console:
logger.addHandler(logging.StreamHandler())
logger.info('Activated console output.')
if parsed_argument.logfile:
logger.addHandler(logging.FileHandler(filename=parsed_argument.logfile))
logger.info('Activated logfile %r output' % parsed_argument.logfile)
if logger is not None:
CONFIG['logger'] = logger.info
config = ConfigParser.SafeConfigParser() config = ConfigParser.SafeConfigParser()
# do not change case of option keys # do not change case of option keys
config.optionxform = str config.optionxform = str
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment