New submission from Niko Yasui: Removed the unnecessary listener function and changed the worker loggers from root to children. Also replaced print statements with logging statements and a stdout handler to illustrate the usefulness of handler levels. This version also doesn't require a manual listener process or thread, since it's all handled by the interpreter in the background.
As far as I know, it's just a one-line change from multiprocessing to threading, so it should be easy to adapt this example to improve the threading example as well. The previous example was hard for me to understand, and when I integrated it to my code, printed duplicates of every log item to all my handlers (including stdout) even though I hadn't added a stdout handler. Evidently this was my fault, since the original example code doesn't do that, but this updated code should be cleaner and easier to understand to avoid such integration problems in the first place. I hope it is a worthy contribution the docs. Feel free to provide any tips to improve it. ---------- assignee: docs@python components: Documentation files: multi_log_cookbook.py messages: 273437 nosy: Niko Yasui, docs@python priority: normal severity: normal status: open title: Logging Cookbook Improvement type: enhancement versions: Python 3.5 Added file: http://bugs.python.org/file44198/multi_log_cookbook.py _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27837> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com