[imp] improved logging, now blacklist openerplib
bzr revid: nicolas.vanhoren@openerp.com-20110929141556-j92hlk7j2ahx8i70
This commit is contained in:
parent
22b1bb8abb
commit
8dbbacca08
|
@ -9,4 +9,3 @@ RE:^include/
|
||||||
RE:^share/
|
RE:^share/
|
||||||
RE:^man/
|
RE:^man/
|
||||||
RE:^lib/
|
RE:^lib/
|
||||||
logging.cfg
|
|
||||||
|
|
|
@ -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"]
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,6 +2,7 @@
|
||||||
import optparse
|
import optparse
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import json
|
||||||
import tempfile
|
import tempfile
|
||||||
import logging
|
import logging
|
||||||
import logging.config
|
import logging.config
|
||||||
|
@ -48,7 +49,7 @@ logging_opts = optparse.OptionGroup(optparser, "Logging")
|
||||||
logging_opts.add_option("--log-level", dest="log_level", type="choice",
|
logging_opts.add_option("--log-level", dest="log_level", type="choice",
|
||||||
default='debug', help="Global logging level", metavar="LOG_LEVEL",
|
default='debug', help="Global logging level", metavar="LOG_LEVEL",
|
||||||
choices=['debug', 'info', 'warning', 'error', 'critical'])
|
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")
|
help="Logging configuration file", metavar="FILE")
|
||||||
optparser.add_option_group(logging_opts)
|
optparser.add_option_group(logging_opts)
|
||||||
|
|
||||||
|
@ -60,10 +61,13 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
os.environ["TZ"] = "UTC"
|
os.environ["TZ"] = "UTC"
|
||||||
|
|
||||||
if not options.log_config:
|
if sys.version_info >= (2, 7):
|
||||||
logging.basicConfig(level=getattr(logging, options.log_level.upper()))
|
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:
|
else:
|
||||||
logging.config.fileConfig(options.log_config)
|
logging.basicConfig(level=getattr(logging, options.log_level.upper()))
|
||||||
|
|
||||||
app = web.common.dispatch.Root(options)
|
app = web.common.dispatch.Root(options)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue