|
0 |
Metadata-Version: 1.1
|
|
1 |
Name: logging_tree
|
|
2 |
Version: 1.9
|
|
3 |
Summary: Introspect and display the logger tree inside "logging"
|
|
4 |
Home-page: https://github.com/brandon-rhodes/logging_tree
|
|
5 |
Author: Brandon Rhodes
|
|
6 |
Author-email: brandon@rhodesmill.org
|
|
7 |
License: UNKNOWN
|
|
8 |
Description: Introspection for the ``logging`` logger tree in the Standard Library.
|
|
9 |
|
|
10 |
You can install this package with the standard ``pip`` command::
|
|
11 |
|
|
12 |
$ pip install logging_tree
|
|
13 |
|
|
14 |
While you can write programs that call this package's ``tree()``
|
|
15 |
function and examine the hierarchy of logger objects that it finds
|
|
16 |
inside of the Standard Library ``logging`` module, the simplest use of
|
|
17 |
this package for debugging is to call ``printout()`` to print the
|
|
18 |
loggers, filters, and handlers that your application has configured::
|
|
19 |
|
|
20 |
>>> logging.getLogger('a')
|
|
21 |
>>> logging.getLogger('a.b').setLevel(logging.DEBUG)
|
|
22 |
>>> logging.getLogger('x.c')
|
|
23 |
>>> from logging_tree import printout
|
|
24 |
>>> printout()
|
|
25 |
<--""
|
|
26 |
Level WARNING
|
|
27 |
|
|
|
28 |
o<--"a"
|
|
29 |
| Level NOTSET so inherits level WARNING
|
|
30 |
| |
|
|
31 |
| o<--"a.b"
|
|
32 |
| Level DEBUG
|
|
33 |
|
|
|
34 |
o<--[x]
|
|
35 |
|
|
|
36 |
o<--"x.c"
|
|
37 |
Level NOTSET so inherits level WARNING
|
|
38 |
|
|
39 |
If you instead want to write the tree diagram to a file, stream, or
|
|
40 |
other file-like object, use::
|
|
41 |
|
|
42 |
file_object.write(logging_tree.format.build_description())
|
|
43 |
|
|
44 |
The logger tree should always print successfully, no matter how
|
|
45 |
complicated. A node whose ``[name]`` is in square brackets is a "place
|
|
46 |
holder" that has never actually been named in a ``getLogger()`` call,
|
|
47 |
but was created automatically to serve as the parent of loggers further
|
|
48 |
down the tree.
|
|
49 |
|
|
50 |
There are several interfaces that ``logging_tree`` supports, depending
|
|
51 |
on how much detail you need.
|
|
52 |
|
|
53 |
``logging_tree.printout(node=None)``
|
|
54 |
|
|
55 |
Prints the current logger tree, or the tree based at the given
|
|
56 |
`node`, to the standard output.
|
|
57 |
|
|
58 |
``logging_tree.format.build_description(node=None)``
|
|
59 |
|
|
60 |
Builds and returns the multi-line description of the current logger
|
|
61 |
tree, or the tree based at the given ``node``, as a single string
|
|
62 |
with newlines inside and a newline at the end.
|
|
63 |
|
|
64 |
``logging_tree.format.describe(node)``
|
|
65 |
|
|
66 |
A generator that yields a series of lines that describe the tree
|
|
67 |
based at the given ``node``. Note that the lines are returned
|
|
68 |
without newline terminators attached.
|
|
69 |
|
|
70 |
``logging_tree.tree()``
|
|
71 |
|
|
72 |
Fetch the current tree of loggers from the ``logging`` module.
|
|
73 |
Returns a node, that is simply a tuple with three fields:
|
|
74 |
|
|
75 |
| ``[0]`` the logger name (``""`` for the root logger).
|
|
76 |
| ``[1]`` the ``logging.Logger`` object itself.
|
|
77 |
| ``[2]`` a list of zero or more child nodes.
|
|
78 |
|
|
79 |
I welcome contributions and ideas as this package matures. You can find
|
|
80 |
the bug tracker at the `repository page on github
|
|
81 |
<https://github.com/brandon-rhodes/logging_tree>`_. Developers can run
|
|
82 |
this package's tests with::
|
|
83 |
|
|
84 |
$ python -m unittest discover logging_tree
|
|
85 |
|
|
86 |
On older versions of Python you will instead have to install
|
|
87 |
``unittest2`` and use its ``unit2`` command line tool to run the tests.
|
|
88 |
|
|
89 |
Changelog
|
|
90 |
---------
|
|
91 |
|
|
92 |
**Version 1.9** - 2021 April 10
|
|
93 |
Declare compatibility with Python 3.9. Improve how the logging
|
|
94 |
module's built-in ``Formatter`` class is displayed under old Python
|
|
95 |
versions where the ``logging`` module uses old-style classes.
|
|
96 |
|
|
97 |
**Version 1.8.1** - 2020 January 26
|
|
98 |
Adjust one test to make it pass under Python 3.8, and update the
|
|
99 |
distribution classifiers to declare compatibility with Python
|
|
100 |
versions through 3.8.
|
|
101 |
|
|
102 |
**Version 1.8** - 2018 August 5
|
|
103 |
Improve the output to better explain what happens if a "parent"
|
|
104 |
attribute has been set to None.
|
|
105 |
|
|
106 |
**Version 1.7** - 2016 January 23
|
|
107 |
Detect whether each logger has the correct "parent" attribute and,
|
|
108 |
if not, print where its log messages are being sent instead.
|
|
109 |
|
|
110 |
**Version 1.6** - 2015 January 8
|
|
111 |
Fixed a crash that would occur if a custom logging Formatter was
|
|
112 |
missing its format string attributes.
|
|
113 |
|
|
114 |
**Version 1.5** - 2014 December 24
|
|
115 |
Handlers now display their logging level if one has been set, and
|
|
116 |
their custom logging formatter if one has been installed.
|
|
117 |
|
|
118 |
**Version 1.4** - 2014 January 8
|
|
119 |
Thanks to a contribution from Dave Brondsema, disabled loggers are
|
|
120 |
now actually marked as "Disabled" to make it less of a surprise that
|
|
121 |
they fail to log anything.
|
|
122 |
|
|
123 |
**Version 1.3** - 2013 October 29
|
|
124 |
Be explicit and display the logger level ``NOTSET`` along with the
|
|
125 |
effective level inherited from the logger's ancestors; and display
|
|
126 |
the list of ``.filters`` of a custom logging handler even though it
|
|
127 |
might contain custom code that ignores them.
|
|
128 |
|
|
129 |
**Version 1.2** - 2013 January 19
|
|
130 |
Compatible with Python 3.3 thanks to @ralphbean.
|
|
131 |
|
|
132 |
**Version 1.1** - 2012 February 17
|
|
133 |
Now compatible with 2.3 <= Python <= 3.2.
|
|
134 |
|
|
135 |
**Version 1.0** - 2012 February 13
|
|
136 |
Can display the handler inside a MemoryHandler; entire public
|
|
137 |
interface documented; 100% test coverage.
|
|
138 |
|
|
139 |
**Version 0.6** - 2012 February 10
|
|
140 |
Added a display format for every ``logging.handlers`` class.
|
|
141 |
|
|
142 |
**Version 0.5** - 2012 February 8
|
|
143 |
Initial release.
|
|
144 |
|
|
145 |
|
|
146 |
Platform: UNKNOWN
|
|
147 |
Classifier: Development Status :: 6 - Mature
|
|
148 |
Classifier: Intended Audience :: Developers
|
|
149 |
Classifier: License :: OSI Approved :: BSD License
|
|
150 |
Classifier: Programming Language :: Python :: 2.3
|
|
151 |
Classifier: Programming Language :: Python :: 2.4
|
|
152 |
Classifier: Programming Language :: Python :: 2.5
|
|
153 |
Classifier: Programming Language :: Python :: 2.6
|
|
154 |
Classifier: Programming Language :: Python :: 2.7
|
|
155 |
Classifier: Programming Language :: Python :: 3.2
|
|
156 |
Classifier: Programming Language :: Python :: 3.3
|
|
157 |
Classifier: Programming Language :: Python :: 3.4
|
|
158 |
Classifier: Programming Language :: Python :: 3.5
|
|
159 |
Classifier: Programming Language :: Python :: 3.6
|
|
160 |
Classifier: Programming Language :: Python :: 3.7
|
|
161 |
Classifier: Programming Language :: Python :: 3.8
|
|
162 |
Classifier: Programming Language :: Python :: 3.9
|
|
163 |
Classifier: Topic :: System :: Logging
|