Commit 03a6e663 authored by Raymond Hettinger's avatar Raymond Hettinger

Fix-up logging.dictConfig() example.

parent 4a8f50a8
...@@ -193,7 +193,7 @@ dictionary:: ...@@ -193,7 +193,7 @@ dictionary::
{"version": 1, {"version": 1,
"formatters": {"brief": {"format": "%(levelname)-8s: %(name)-15s: %(message)s"}, "formatters": {"brief": {"format": "%(levelname)-8s: %(name)-15s: %(message)s"},
"full": {"format": "%(asctime)s %(name)-15s %(levelname)-8s %(message)s"}, "full": {"format": "%(asctime)s %(name)-15s %(levelname)-8s %(message)s"}
}, },
"handlers": {"console": { "handlers": {"console": {
"class": "logging.StreamHandler", "class": "logging.StreamHandler",
...@@ -204,7 +204,7 @@ dictionary:: ...@@ -204,7 +204,7 @@ dictionary::
"class": "logging.StreamHandler", "class": "logging.StreamHandler",
"formatter": "full", "formatter": "full",
"level": "ERROR", "level": "ERROR",
"stream": "ext://sys.stderr"}, "stream": "ext://sys.stderr"}
}, },
"root": {"level": "DEBUG", "handlers": ["console", "console_priority"]}} "root": {"level": "DEBUG", "handlers": ["console", "console_priority"]}}
...@@ -213,11 +213,13 @@ If that dictionary is stored in a file called :file:`conf.json`, it can be ...@@ -213,11 +213,13 @@ If that dictionary is stored in a file called :file:`conf.json`, it can be
loaded and called with code like this:: loaded and called with code like this::
>>> import json, logging.config >>> import json, logging.config
>>> with open('conf.json', 'rb') as f: >>> with open('conf.json') as f:
conf = json.load(f) conf = json.load(f)
>>> logging.config.dictConfig(conf) >>> logging.config.dictConfig(conf)
>>> logging.info("Transaction completed normally") >>> logging.info("Transaction completed normally")
INFO : root : Transaction completed normally
>>> logging.critical("Abnormal termination") >>> logging.critical("Abnormal termination")
2011-02-17 11:14:36,694 root CRITICAL Abnormal termination
.. seealso:: .. seealso::
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment