Package: logging_tree
Introspection for thelogginglogger tree in the Standard Library.You can install this package with the standardpipcommand:$ pip install logging_treeWhile you can write programs that call this package’stree()function and examine the hierarchy of logger objects that it finds
inside of the Standard Libraryloggingmodule, the simplest use of
this package for debugging is to callprintout()to print the
loggers, filters, and handlers that your application has configured:>>> logging.getLogger('a')
>>> logging.getLogger('a.b').setLevel(logging.DEBUG)
>>> logging.getLogger('x.c')
>>> from logging_tree import printout
>>> printout()
<--""
   Level WARNING
   |
   o<--"a"
   |   Level NOTSET so inherits level WARNING
   |   |
   |   o<--"a.b"
   |       Level DEBUG
   |
   o<--[x]
       |
       o<--"x.c"
           Level NOTSET so inherits level WARNINGIf you instead want to write the tree diagram to a file, stream, or
other file-like object, use:file_object.write(logging_tree.format.build_description())The logger tree should always print successfully, no matter how
complicated.  A node whose[name]is in square brackets is a “place
holder” that has never actually been named in agetLogger()call,
but was created automatically to serve as the parent of loggers further
down the tree.There are several interfaces thatlogging_treesupports, depending
on how much detail you need.logging_tree.printout(node=None)Prints the current logger tree, or the tree based at the givennode, to the standard output.logging_tree.format.build_description(node=None)Builds and returns the multi-line description of the current logger
tree, or the tree based at the givennode, as a single string
with newlines inside and a newline at the end.logging_tree.format.describe(node)A generator that yields a series of lines that describe the tree
based at the givennode.  Note that the lines are returned
without newline terminators attached.logging_tree.tree()Fetch the current tree of loggers from theloggingmodule.
Returns a node, that is simply a tuple with three fields:[0]the logger name (""for the root logger).[1]thelogging.Loggerobject itself.[2]a list of zero or more child nodes.I welcome contributions and ideas as this package matures.  You can find
the bug tracker at therepository page on github.  Developers can run
this package’s tests with:$ python -m unittest discover logging_treeOn older versions of Python you will instead have to installunittest2and use itsunit2command line tool to run the tests.ChangelogVersion 1.9- 2021 April 10Declare compatibility with Python 3.9.  Improve how the logging
module’s built-inFormatterclass is displayed under old Python
versions where theloggingmodule uses old-style classes.Version 1.8.1- 2020 January 26Adjust one test to make it pass under Python 3.8, and update the
distribution classifiers to declare compatibility with Python
versions through 3.8.Version 1.8- 2018 August 5Improve the output to better explain what happens if a “parent”
attribute has been set to None.Version 1.7- 2016 January 23Detect whether each logger has the correct “parent” attribute and,
if not, print where its log messages are being sent instead.Version 1.6- 2015 January 8Fixed a crash that would occur if a custom logging Formatter was
missing its format string attributes.Version 1.5- 2014 December 24Handlers now display their logging level if one has been set, and
their custom logging formatter if one has been installed.Version 1.4- 2014 January 8Thanks to a contribution from Dave Brondsema, disabled loggers are
now actually marked as “Disabled” to make it less of a surprise that
they fail to log anything.Version 1.3- 2013 October 29Be explicit and display the logger levelNOTSETalong with the
effective level inherited from the logger’s ancestors; and display
the list of.filtersof a custom logging handler even though it
might contain custom code that ignores them.Version 1.2- 2013 January 19Compatible with Python 3.3 thanks to @ralphbean.Version 1.1- 2012 February 17Now compatible with 2.3 <= Python <= 3.2.Version 1.0- 2012 February 13Can display the handler inside a MemoryHandler; entire public
interface documented; 100% test coverage.Version 0.6- 2012 February 10Added a display format for everylogging.handlersclass.Version 0.5- 2012 February 8Initial release.