--- /dev/null
+{
+ "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"]
+ }
+}
import optparse
import os
import sys
+import json
import tempfile
import logging
import logging.config
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)
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)