diff options
| author | niv-openerp <nicolas.vanhoren@openerp.com> | 2011-09-29 16:15:56 +0200 |
|---|---|---|
| committer | niv-openerp <nicolas.vanhoren@openerp.com> | 2011-09-29 16:15:56 +0200 |
| commit | 8dbbacca082f0f2c3355971527c2addd677cecae (patch) | |
| tree | 2afd4e2ae17866f1fb9dce44c67f8638f4d8d9a4 | |
| parent | 22b1bb8abb0cb7148d0cbeadea1fe0aba2e11f97 (diff) | |
[imp] improved logging, now blacklist openerplib
bzr revid: nicolas.vanhoren@openerp.com-20110929141556-j92hlk7j2ahx8i70
| -rw-r--r-- | .bzrignore | 1 | ||||
| -rw-r--r-- | logging.json | 27 | ||||
| -rwxr-xr-x | openerp-web.py | 12 |
3 files changed, 35 insertions, 5 deletions
diff --git a/.bzrignore b/.bzrignore index 7ae985ce4df..b83a43bf1d4 100644 --- a/.bzrignore +++ b/.bzrignore @@ -9,4 +9,3 @@ RE:^include/ RE:^share/ RE:^man/ RE:^lib/ -logging.cfg diff --git a/logging.json b/logging.json new file mode 100644 index 00000000000..36b2952a6ec --- /dev/null +++ b/logging.json @@ -0,0 +1,27 @@ +{ + "version": 1, + "formatters": { + "simple": { + "format": "%(asctime)s - %(name)s - %(levelname)s - %(message)s" + } + }, + "handlers": { + "console": { + "class": "logging.StreamHandler", + "level": "DEBUG", + "formatter": "simple", + "stream": "ext://sys.stdout" + } + }, + "loggers": { + "web": { + }, + "web.common.openerplib": { + "level": "INFO" + } + }, + "root": { + "level": "DEBUG", + "handlers": ["console"] + } +} diff --git a/openerp-web.py b/openerp-web.py index 928a62e4528..e167568cdab 100755 --- a/openerp-web.py +++ b/openerp-web.py @@ -2,6 +2,7 @@ import optparse import os import sys +import json import tempfile import logging import logging.config @@ -48,7 +49,7 @@ logging_opts = optparse.OptionGroup(optparser, "Logging") logging_opts.add_option("--log-level", dest="log_level", type="choice", default='debug', help="Global logging level", metavar="LOG_LEVEL", choices=['debug', 'info', 'warning', 'error', 'critical']) -logging_opts.add_option("--log-config", dest="log_config", +logging_opts.add_option("--log-config", dest="log_config", default=os.path.join(os.path.dirname(__file__), "logging.json"), help="Logging configuration file", metavar="FILE") optparser.add_option_group(logging_opts) @@ -60,10 +61,13 @@ if __name__ == "__main__": os.environ["TZ"] = "UTC" - if not options.log_config: - logging.basicConfig(level=getattr(logging, options.log_level.upper())) + if sys.version_info >= (2, 7): + with open(options.log_config) as file: + dct = json.load(file) + logging.config.dictConfig(dct) + logging.getLogger("").setLevel(getattr(logging, options.log_level.upper())) else: - logging.config.fileConfig(options.log_config) + logging.basicConfig(level=getattr(logging, options.log_level.upper())) app = web.common.dispatch.Root(options) |
