Add an option to use a log file, this will made debugging easier

parent 3c9acec4
...@@ -178,6 +178,11 @@ def _get_parser(): ...@@ -178,6 +178,11 @@ def _get_parser():
dest="log", dest="log",
default="info", default="info",
help="logging level: debug, info, warning, error, critical") help="logging level: debug, info, warning, error, critical")
parser.add_argument(
"--logfile",
help="path to the optional log file",
default=None,
dest="logfile")
parser.add_argument( parser.add_argument(
"-p", "--prefix", "-p", "--prefix",
dest="prefix_code", dest="prefix_code",
......
...@@ -42,7 +42,7 @@ def set_logging_level(options): ...@@ -42,7 +42,7 @@ def set_logging_level(options):
if not isinstance(numeric_level, int): if not isinstance(numeric_level, int):
sys.exit('Invalid log level: %s' % options.log) sys.exit('Invalid log level: %s' % options.log)
if not shell.check_windows(): if not shell.check_windows() and options.logfile == None:
logging.basicConfig( logging.basicConfig(
format=colored( format=colored(
"%(levelname)s", "%(levelname)s",
...@@ -55,7 +55,8 @@ def set_logging_level(options): ...@@ -55,7 +55,8 @@ def set_logging_level(options):
format="%(levelname)s" + format="%(levelname)s" +
"\t%(filename)s:%(lineno)d: %(funcName)s()\t" + "\t%(filename)s:%(lineno)d: %(funcName)s()\t" +
"%(message)s", "%(message)s",
level=numeric_level) level=numeric_level,
filename=options.logfile)
logging.debug(str(options)) logging.debug(str(options))
......
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