summaryrefslogtreecommitdiff
path: root/src/leap/app.py
diff options
context:
space:
mode:
authorkali <kali@leap.se>2012-09-05 07:54:10 +0900
committerkali <kali@leap.se>2012-09-05 07:54:10 +0900
commit813a97957572aad97d50319db96b55a74b8ed307 (patch)
treee559f10fe8a3f9c5746a29ae8bd2aa808998e552 /src/leap/app.py
parenta2804c3de1470db98d8c6aa8a01e2de1aa1718a1 (diff)
can log to logfile
app.py --debug --logfile /tmp/foo.log
Diffstat (limited to 'src/leap/app.py')
-rw-r--r--src/leap/app.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/leap/app.py b/src/leap/app.py
index 3864ffeb..1ab806ca 100644
--- a/src/leap/app.py
+++ b/src/leap/app.py
@@ -17,6 +17,7 @@ def main():
parser, opts = leap_argparse.init_leapc_args()
debug = getattr(opts, 'debug', False)
+ # XXX get severity from command line args
if debug:
level = logging.DEBUG
else:
@@ -31,6 +32,15 @@ def main():
'- %(name)s - %(levelname)s - %(message)s')
console.setFormatter(formatter)
logger.addHandler(console)
+
+ logfile = getattr(opts, 'log_file', False)
+ if logfile:
+ logger.debug('setting logfile ', logfile)
+ fileh = logging.FileHandler(logfile)
+ fileh.setLevel(logging.DEBUG)
+ fileh.setFormatter(formatter)
+ logger.addHandler(fileh)
+
logger.debug('args: %s' % opts)
logger.info('Starting app')