diff options
author | André Erdmann <dywi@mailerd.de> | 2012-07-03 19:42:53 +0200 |
---|---|---|
committer | André Erdmann <dywi@mailerd.de> | 2012-07-03 19:42:53 +0200 |
commit | 19da5ea18f1e5010b369ee259c4a4f7fd4d501aa (patch) | |
tree | 269c289b2c91bb0508df4b714478e4f3026d28be /roverlay/recipe | |
parent | DescriptionReader logging (diff) | |
download | R_overlay-19da5ea18f1e5010b369ee259c4a4f7fd4d501aa.tar.gz R_overlay-19da5ea18f1e5010b369ee259c4a4f7fd4d501aa.tar.bz2 R_overlay-19da5ea18f1e5010b369ee259c4a4f7fd4d501aa.zip |
roverlay, __init__
* using recipe/easylogger to set up logging
* config file is no longer loaded automatically
modified: roverlay/__init__.py
new file: roverlay/recipe/easylogger.py
Diffstat (limited to 'roverlay/recipe')
-rw-r--r-- | roverlay/recipe/easylogger.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/roverlay/recipe/easylogger.py b/roverlay/recipe/easylogger.py new file mode 100644 index 0000000..112d07b --- /dev/null +++ b/roverlay/recipe/easylogger.py @@ -0,0 +1,39 @@ +# R Overlay +# Copyright 2006-2012 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +import logging + +_STATUS = 0 + +def setup ( conf ): + global _STATUS + if _STATUS > 1: + return + + logging.basicConfig ( + level=logging.DEBUG, + filename=conf.get ( [ 'LOG', 'FILE', 'main' ], 'roverlay.log' ), + filemode='a', + format='%(asctime)s %(levelname)-8s %(name)-14s -- %(message)s', + datefmt='%F %H:%M:%S' + ) + + # add console output to the logger + ch = logging.StreamHandler() + ch.setLevel ( logging.DEBUG ) + ch.setFormatter ( + logging.Formatter ( '%(levelname)-8s %(name)-14s -- %(message)s' ) + ) + logging.getLogger().addHandler ( ch ) + + _STATUS = 2 + +def setup_initial(): + global _STATUS + if _STATUS > 0: + return + + pass + + _STATUS = 1 |