ictr 1.0a0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ictr-1.0a0/.gitignore +7 -0
- ictr-1.0a0/LICENSE.txt +202 -0
- ictr-1.0a0/PKG-INFO +406 -0
- ictr-1.0a0/README.rst +368 -0
- ictr-1.0a0/pyproject.toml +377 -0
- ictr-1.0a0/sources/ictr/__/__init__.py +27 -0
- ictr-1.0a0/sources/ictr/__/imports.py +61 -0
- ictr-1.0a0/sources/ictr/__/miscellany.py +34 -0
- ictr-1.0a0/sources/ictr/__/nomina.py +54 -0
- ictr-1.0a0/sources/ictr/__/validators.py +77 -0
- ictr-1.0a0/sources/ictr/__init__.py +39 -0
- ictr-1.0a0/sources/ictr/_typedecls/wcwidth/__init__.pyi +9 -0
- ictr-1.0a0/sources/ictr/configuration.py +107 -0
- ictr-1.0a0/sources/ictr/dispatchers.py +666 -0
- ictr-1.0a0/sources/ictr/exceptions.py +89 -0
- ictr-1.0a0/sources/ictr/flavors.py +77 -0
- ictr-1.0a0/sources/ictr/inspection.py +46 -0
- ictr-1.0a0/sources/ictr/printers.py +175 -0
- ictr-1.0a0/sources/ictr/py.typed +0 -0
- ictr-1.0a0/sources/ictr/records.py +53 -0
- ictr-1.0a0/sources/ictr/reporters.py +62 -0
- ictr-1.0a0/sources/ictr/standard/__.py +62 -0
- ictr-1.0a0/sources/ictr/standard/__init__.py +29 -0
- ictr-1.0a0/sources/ictr/standard/compositors.py +197 -0
- ictr-1.0a0/sources/ictr/standard/core.py +330 -0
- ictr-1.0a0/sources/ictr/standard/flavors.py +77 -0
- ictr-1.0a0/sources/ictr/standard/introducers.py +146 -0
- ictr-1.0a0/sources/ictr/standard/linearizers.py +239 -0
- ictr-1.0a0/sources/ictr/standard/printers.py +62 -0
- ictr-1.0a0/sources/ictr/textualizers.py +106 -0
ictr-1.0a0/.gitignore
ADDED
ictr-1.0a0/LICENSE.txt
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
ictr-1.0a0/PKG-INFO
ADDED
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ictr
|
|
3
|
+
Version: 1.0a0
|
|
4
|
+
Summary: Non-intrusive system for logging and debug printing.
|
|
5
|
+
Project-URL: Homepage, https://github.com/emcd/python-ictr
|
|
6
|
+
Project-URL: Documentation, https://emcd.github.io/python-ictr
|
|
7
|
+
Project-URL: Download, https://pypi.org/project/ictr/#files
|
|
8
|
+
Project-URL: Source Code, https://github.com/emcd/python-ictr
|
|
9
|
+
Project-URL: Issue Tracker, https://github.com/emcd/python-ictr/issues
|
|
10
|
+
Author-email: Eric McDonald <emcd@users.noreply.github.com>
|
|
11
|
+
License-Expression: Apache-2.0
|
|
12
|
+
License-File: LICENSE.txt
|
|
13
|
+
Keywords: debug,introspection,logging,print
|
|
14
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
17
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
23
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
24
|
+
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
25
|
+
Classifier: Topic :: Software Development
|
|
26
|
+
Requires-Python: >=3.10
|
|
27
|
+
Requires-Dist: absence~=1.1
|
|
28
|
+
Requires-Dist: accretive~=4.2
|
|
29
|
+
Requires-Dist: colorama
|
|
30
|
+
Requires-Dist: dynadoc~=1.4
|
|
31
|
+
Requires-Dist: exceptiongroup~=1.3
|
|
32
|
+
Requires-Dist: frigid~=4.2
|
|
33
|
+
Requires-Dist: typing-extensions~=4.15
|
|
34
|
+
Requires-Dist: wcwidth~=0.2.14
|
|
35
|
+
Provides-Extra: deluxe
|
|
36
|
+
Requires-Dist: rich~=14.2; extra == 'deluxe'
|
|
37
|
+
Description-Content-Type: text/x-rst
|
|
38
|
+
|
|
39
|
+
.. vim: set fileencoding=utf-8:
|
|
40
|
+
.. -*- coding: utf-8 -*-
|
|
41
|
+
.. +--------------------------------------------------------------------------+
|
|
42
|
+
| |
|
|
43
|
+
| Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
44
|
+
| you may not use this file except in compliance with the License. |
|
|
45
|
+
| You may obtain a copy of the License at |
|
|
46
|
+
| |
|
|
47
|
+
| http://www.apache.org/licenses/LICENSE-2.0 |
|
|
48
|
+
| |
|
|
49
|
+
| Unless required by applicable law or agreed to in writing, software |
|
|
50
|
+
| distributed under the License is distributed on an "AS IS" BASIS, |
|
|
51
|
+
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
|
52
|
+
| See the License for the specific language governing permissions and |
|
|
53
|
+
| limitations under the License. |
|
|
54
|
+
| |
|
|
55
|
+
+--------------------------------------------------------------------------+
|
|
56
|
+
|
|
57
|
+
*******************************************************************************
|
|
58
|
+
ictr
|
|
59
|
+
*******************************************************************************
|
|
60
|
+
|
|
61
|
+
.. image:: https://img.shields.io/pypi/v/ictr
|
|
62
|
+
:alt: Package Version
|
|
63
|
+
:target: https://pypi.org/project/ictr/
|
|
64
|
+
|
|
65
|
+
.. image:: https://img.shields.io/pypi/status/ictr
|
|
66
|
+
:alt: PyPI - Status
|
|
67
|
+
:target: https://pypi.org/project/ictr/
|
|
68
|
+
|
|
69
|
+
.. image:: https://github.com/emcd/python-ictr/actions/workflows/tester.yaml/badge.svg?branch=master&event=push
|
|
70
|
+
:alt: Tests Status
|
|
71
|
+
:target: https://github.com/emcd/python-ictr/actions/workflows/tester.yaml
|
|
72
|
+
|
|
73
|
+
.. image:: https://emcd.github.io/python-ictr/coverage.svg
|
|
74
|
+
:alt: Code Coverage Percentage
|
|
75
|
+
:target: https://github.com/emcd/python-ictr/actions/workflows/tester.yaml
|
|
76
|
+
|
|
77
|
+
.. image:: https://img.shields.io/github/license/emcd/python-ictr
|
|
78
|
+
:alt: Project License
|
|
79
|
+
:target: https://github.com/emcd/python-ictr/blob/master/LICENSE.txt
|
|
80
|
+
|
|
81
|
+
.. image:: https://img.shields.io/pypi/pyversions/ictr
|
|
82
|
+
:alt: Python Versions
|
|
83
|
+
:target: https://pypi.org/project/ictr/
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
🖋️ **Ictr** is a system for logging and debug printing in Python applications.
|
|
87
|
+
It provides a clean, type-safe API for emitting diagnostic messages with
|
|
88
|
+
minimal boilerplate, featuring standard message flavors, hierarchical trace
|
|
89
|
+
levels for debugging depth, automatic exception tracebacks, and optional rich
|
|
90
|
+
rendering with colors and styling.
|
|
91
|
+
|
|
92
|
+
Designed as an alternative to traditional print debugging and verbose logging
|
|
93
|
+
setup, ``ictr`` can install a global dispatcher into the Python builtins,
|
|
94
|
+
similar to the well-known `icecream <https://github.com/gruns/icecream>`_
|
|
95
|
+
package, for effortless access throughout your application — no import
|
|
96
|
+
statements needed in every module. Perfect for both quick debugging sessions
|
|
97
|
+
and production logging with per-module configuration.
|
|
98
|
+
|
|
99
|
+
Key Features ⭐
|
|
100
|
+
===============================================================================
|
|
101
|
+
|
|
102
|
+
🎨 **Standard Message Flavors**: Pre-configured ``note``, ``monition``,
|
|
103
|
+
``error``, ``abort``, ``future``, ``success``, and ``advice`` flavors with
|
|
104
|
+
semantic labels and optional emoji/color styling.
|
|
105
|
+
|
|
106
|
+
🔢 **Hierarchical Trace Levels**: Ten trace levels (0-9) with automatic
|
|
107
|
+
indentation for visualizing call depth and execution flow.
|
|
108
|
+
|
|
109
|
+
💥 **Automatic Exception Tracebacks**: ``errorx`` and ``abortx`` flavors
|
|
110
|
+
capture and format active exceptions with full stack traces.
|
|
111
|
+
|
|
112
|
+
🌳 **Module Hierarchy**: Global and per-module configs with inheritance for
|
|
113
|
+
precise control over active flavors, trace levels, output formatting, etc....
|
|
114
|
+
|
|
115
|
+
🚀 **Zero-Import Access**: Global dispatcher available in builtins after
|
|
116
|
+
initial setup — no import statements needed in every module.
|
|
117
|
+
|
|
118
|
+
🖨️ **Printer Factory**: Dynamically associate output functions with reporters
|
|
119
|
+
based on module name, flavor, etc.... Swap in customized ``print``,
|
|
120
|
+
``logging``, or other sinks as desired.
|
|
121
|
+
|
|
122
|
+
📚 **Library-Friendly**: Non-intrusive registration for libraries without
|
|
123
|
+
stepping on application debugger/logging configuration.
|
|
124
|
+
|
|
125
|
+
Installation 📦
|
|
126
|
+
===============================================================================
|
|
127
|
+
|
|
128
|
+
Method: Install Python Package
|
|
129
|
+
-------------------------------------------------------------------------------
|
|
130
|
+
|
|
131
|
+
Install via `uv <https://github.com/astral-sh/uv/blob/main/README.md>`_ ``pip``
|
|
132
|
+
command:
|
|
133
|
+
|
|
134
|
+
::
|
|
135
|
+
|
|
136
|
+
uv pip install ictr
|
|
137
|
+
|
|
138
|
+
Or, install via ``pip``:
|
|
139
|
+
|
|
140
|
+
::
|
|
141
|
+
|
|
142
|
+
pip install ictr
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
Examples 💡
|
|
146
|
+
===============================================================================
|
|
147
|
+
|
|
148
|
+
For more detailed examples, please see the `examples documentation
|
|
149
|
+
<https://emcd.github.io/python-ictr/stable/sphinx-html/examples/index.html>`_.
|
|
150
|
+
|
|
151
|
+
Basic Usage
|
|
152
|
+
-------------------------------------------------------------------------------
|
|
153
|
+
|
|
154
|
+
Install an ``ictr`` dispatcher as a Python builtin (default alias, ``ictr``)
|
|
155
|
+
and then use it anywhere in your codebase:
|
|
156
|
+
|
|
157
|
+
.. code-block:: python
|
|
158
|
+
|
|
159
|
+
import ictr
|
|
160
|
+
|
|
161
|
+
ictr.install( )
|
|
162
|
+
|
|
163
|
+
# Emit messages with different flavors
|
|
164
|
+
ictr( 'note' )( 'Application started.' ) # NOTE| Application started.
|
|
165
|
+
ictr( 'error' )( 'Connection failed.' ) # ERROR| Connection failed.
|
|
166
|
+
ictr( 'success' )( 'Task completed.' ) # SUCCESS| Task completed.
|
|
167
|
+
|
|
168
|
+
Trace Levels
|
|
169
|
+
-------------------------------------------------------------------------------
|
|
170
|
+
|
|
171
|
+
Use numeric trace levels (0-9) for hierarchical debugging output:
|
|
172
|
+
|
|
173
|
+
.. code-block:: python
|
|
174
|
+
|
|
175
|
+
import ictr
|
|
176
|
+
|
|
177
|
+
ictr.install( trace_levels = { None: 3 } ) # Enable levels 0-3 globally
|
|
178
|
+
|
|
179
|
+
ictr( 0 )( 'Top-level operation' ) # TRACE0| Top-level operation
|
|
180
|
+
ictr( 1 )( 'Sub-operation details' ) # TRACE1| Sub-operation details
|
|
181
|
+
ictr( 2 )( 'More detail' ) # TRACE2| More detail
|
|
182
|
+
ictr( 4 )( 'Too verbose' ) # (suppressed - level > 3)
|
|
183
|
+
|
|
184
|
+
Exception Handling
|
|
185
|
+
-------------------------------------------------------------------------------
|
|
186
|
+
|
|
187
|
+
Use ``errorx`` or ``abortx`` flavors to capture active exceptions with
|
|
188
|
+
tracebacks:
|
|
189
|
+
|
|
190
|
+
.. code-block:: python
|
|
191
|
+
|
|
192
|
+
import ictr
|
|
193
|
+
|
|
194
|
+
ictr.install( )
|
|
195
|
+
|
|
196
|
+
try:
|
|
197
|
+
result = 1 / 0
|
|
198
|
+
except ZeroDivisionError:
|
|
199
|
+
ictr( 'errorx' )( 'Calculation failed.' )
|
|
200
|
+
# ERROR| Calculation failed.
|
|
201
|
+
#
|
|
202
|
+
# [ZeroDivisionError] division by zero
|
|
203
|
+
# File 'example.py', line 8, in <module>
|
|
204
|
+
# result = 1 / 0
|
|
205
|
+
|
|
206
|
+
Library Integration
|
|
207
|
+
-------------------------------------------------------------------------------
|
|
208
|
+
|
|
209
|
+
Libraries can register their own configurations without overriding those of the
|
|
210
|
+
application:
|
|
211
|
+
|
|
212
|
+
.. code-block:: python
|
|
213
|
+
|
|
214
|
+
# mylibrary/__init__.py
|
|
215
|
+
import ictr
|
|
216
|
+
|
|
217
|
+
ictr.register_address( 'mylibrary' )
|
|
218
|
+
|
|
219
|
+
When ``install`` is called by the application, any addresses that were
|
|
220
|
+
previously registered via ``register_address`` are incorporated into the
|
|
221
|
+
installed dispatcher. This allows applications to setup output after libraries
|
|
222
|
+
have registered their configurations.
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
Motivation 🚚
|
|
226
|
+
===============================================================================
|
|
227
|
+
|
|
228
|
+
Why ``ictr``?
|
|
229
|
+
|
|
230
|
+
There is nothing wrong with the ``icecream`` or ``logging`` packages. However,
|
|
231
|
+
there are times that the author of ``ictr`` (and its predecessor,
|
|
232
|
+
``icecream-truck``) has wanted, for various reasons, more than these packages
|
|
233
|
+
inherently offer:
|
|
234
|
+
|
|
235
|
+
* **Coexistence**: Application and libraries can coexist without configuration
|
|
236
|
+
clashes.
|
|
237
|
+
|
|
238
|
+
- Library developers are `strongly advised not to create custom levels
|
|
239
|
+
<https://docs.python.org/3/howto/logging.html#custom-levels>`_ in
|
|
240
|
+
``logging``.
|
|
241
|
+
|
|
242
|
+
- Library developers are `advised on how to avoid polluting stderr
|
|
243
|
+
<https://docs.python.org/3/howto/logging.html#configuring-logging-for-a-library>`_
|
|
244
|
+
in ``logging``, when an application has not supplied a configuration.
|
|
245
|
+
|
|
246
|
+
- Loggers `propagate upwards
|
|
247
|
+
<https://docs.python.org/3/library/logging.html#logging.Logger.propagate>`_
|
|
248
|
+
by default in ``logging``. This means that libraries must explicitly
|
|
249
|
+
opt-out of propagation if their authors want to be good citizens and not
|
|
250
|
+
contribute to noise pollution / signal obfuscation.
|
|
251
|
+
|
|
252
|
+
* **Granularity**: Control of debug output by depth threshold and subsystem.
|
|
253
|
+
|
|
254
|
+
- Only one default debugging level (``DEBUG``) with ``logging``. Libraries
|
|
255
|
+
cannot safely extend this. (See point about coexistence).
|
|
256
|
+
|
|
257
|
+
- No concept of debugging level with ``ic`` builtin. Need to orchestrate
|
|
258
|
+
multiple ``icecream.IceCreamDebugger`` instances to support this. (In
|
|
259
|
+
fact, this is what ``icecream-truck`` does.)
|
|
260
|
+
|
|
261
|
+
- While logger hierarchies in ``logging`` do support the notion of software
|
|
262
|
+
subsystems, hierarchies are not always the most convenient or abbreviated
|
|
263
|
+
way of representing subsystems which span parts or entireties of modules.
|
|
264
|
+
|
|
265
|
+
* **Signal**: Prevention of undesirable library chatter.
|
|
266
|
+
|
|
267
|
+
- The ``logging`` root logger will log all messages, at its current log
|
|
268
|
+
level or higher, which propagate up to it. Many Python libraries have
|
|
269
|
+
opt-out rather than opt-in logging, so you see all of their ``DEBUG`` and
|
|
270
|
+
``INFO`` spam unless you surgically manipulate their loggers or squelch
|
|
271
|
+
the overall log level.
|
|
272
|
+
|
|
273
|
+
- Use of the ``ic`` builtin is only recommended for temporary debugging. It
|
|
274
|
+
cannot be left in production code without spamming. While the ``enabled``
|
|
275
|
+
flag on the ``ic`` builtin can be set to false, it is easy to forget and
|
|
276
|
+
also applies to every place where ``ic`` is used in the code. (See point
|
|
277
|
+
about granularity.)
|
|
278
|
+
|
|
279
|
+
* **Extensibility**: More natural integration with packages like ``rich`` via
|
|
280
|
+
robust recipes.
|
|
281
|
+
|
|
282
|
+
- While it is not difficult to change the ``argToStringFunction`` on ``ic``
|
|
283
|
+
to be ``rich.pretty.pretty_repr``, there is some repetitive code involved
|
|
284
|
+
in each project which wants to do this. And, from a safety perspective,
|
|
285
|
+
there should be a fallback if ``rich`` fails to import.
|
|
286
|
+
|
|
287
|
+
- Similarly, one can add a ``rich.logging.RichHandler`` instance to a
|
|
288
|
+
logger instance with minimal effort. However, depending on the the target
|
|
289
|
+
output stream, one may also need to build a ``rich.console.Console`` first
|
|
290
|
+
and pass that to the handler. This handler will also compete with whatever
|
|
291
|
+
handler has been set on the root logger. So, some care must be taken to
|
|
292
|
+
prevent propagation. Again, this is repetitive code across projects and
|
|
293
|
+
there are import safety fallbacks to consider.
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
About the Name 📝
|
|
297
|
+
===============================================================================
|
|
298
|
+
|
|
299
|
+
The name ``ictr`` has multiple origins and interpretations:
|
|
300
|
+
|
|
301
|
+
* 🍦 **Shortened from icecream-truck**: The package from which ``ictr`` is
|
|
302
|
+
derived and redesigned. The abbreviation maintains the connection to its
|
|
303
|
+
predecessor while establishing its own identity.
|
|
304
|
+
|
|
305
|
+
* 🎯 **Short and memorable**: Four letters that are easy to type and remember.
|
|
306
|
+
The Python package distribution name and import name are the same, reducing
|
|
307
|
+
cognitive overhead.
|
|
308
|
+
|
|
309
|
+
* 📊 **Backronym interpretations**: While ``ictr`` works perfectly well as
|
|
310
|
+
just a name, several backronyms capture different aspects of its purpose:
|
|
311
|
+
|
|
312
|
+
- **Inspection-Capable Trace Reporting** (emphasizes diagnostic capabilities)
|
|
313
|
+
- **Intelligent Configurable Trace Reporter** (emphasizes smart behavior)
|
|
314
|
+
- **I See Textual Reports** (playful take on the phonetic sound)
|
|
315
|
+
|
|
316
|
+
Pronunciation? You can spell it out. But, if that is too many syllables, then
|
|
317
|
+
maybe "eyes-tra" but probably not "ick-ter", because it is not that revulsive.
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
Contribution 🤝
|
|
321
|
+
===============================================================================
|
|
322
|
+
|
|
323
|
+
Contribution to this project is welcome! However, it must follow the `code of
|
|
324
|
+
conduct
|
|
325
|
+
<https://emcd.github.io/python-project-common/stable/sphinx-html/common/conduct.html>`_
|
|
326
|
+
for the project.
|
|
327
|
+
|
|
328
|
+
Please file bug reports and feature requests in the `issue tracker
|
|
329
|
+
<https://github.com/emcd/python-ictr/issues>`_ or submit `pull
|
|
330
|
+
requests <https://github.com/emcd/python-ictr/pulls>`_ to
|
|
331
|
+
improve the source code or documentation.
|
|
332
|
+
|
|
333
|
+
For development guidance and standards, please see the `development guide
|
|
334
|
+
<https://emcd.github.io/python-ictr/stable/sphinx-html/contribution.html#development>`_.
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
Additional Indicia
|
|
338
|
+
===============================================================================
|
|
339
|
+
|
|
340
|
+
.. image:: https://img.shields.io/github/last-commit/emcd/python-ictr
|
|
341
|
+
:alt: GitHub last commit
|
|
342
|
+
:target: https://github.com/emcd/python-ictr
|
|
343
|
+
|
|
344
|
+
.. image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/copier-org/copier/master/img/badge/badge-grayscale-inverted-border-orange.json
|
|
345
|
+
:alt: Copier
|
|
346
|
+
:target: https://github.com/copier-org/copier
|
|
347
|
+
|
|
348
|
+
.. image:: https://img.shields.io/badge/%F0%9F%A5%9A-Hatch-4051b5.svg
|
|
349
|
+
:alt: Hatch
|
|
350
|
+
:target: https://github.com/pypa/hatch
|
|
351
|
+
|
|
352
|
+
.. image:: https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit
|
|
353
|
+
:alt: pre-commit
|
|
354
|
+
:target: https://github.com/pre-commit/pre-commit
|
|
355
|
+
|
|
356
|
+
.. image:: https://microsoft.github.io/pyright/img/pyright_badge.svg
|
|
357
|
+
:alt: Pyright
|
|
358
|
+
:target: https://microsoft.github.io/pyright
|
|
359
|
+
|
|
360
|
+
.. image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
|
|
361
|
+
:alt: Ruff
|
|
362
|
+
:target: https://github.com/astral-sh/ruff
|
|
363
|
+
|
|
364
|
+
.. image:: https://img.shields.io/pypi/implementation/ictr
|
|
365
|
+
:alt: PyPI - Implementation
|
|
366
|
+
:target: https://pypi.org/project/ictr/
|
|
367
|
+
|
|
368
|
+
.. image:: https://img.shields.io/pypi/wheel/ictr
|
|
369
|
+
:alt: PyPI - Wheel
|
|
370
|
+
:target: https://pypi.org/project/ictr/
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
Other Projects by This Author 🌟
|
|
374
|
+
===============================================================================
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
* `python-absence <https://github.com/emcd/python-absence>`_ (`absence <https://pypi.org/project/absence/>`_ on PyPI)
|
|
378
|
+
|
|
379
|
+
🕳️ A Python library package which provides a **sentinel for absent values** - a falsey, immutable singleton that represents the absence of a value in contexts where ``None`` or ``False`` may be valid values.
|
|
380
|
+
* `python-accretive <https://github.com/emcd/python-accretive>`_ (`accretive <https://pypi.org/project/accretive/>`_ on PyPI)
|
|
381
|
+
|
|
382
|
+
🌌 A Python library package which provides **accretive data structures** - collections which can grow but never shrink.
|
|
383
|
+
* `python-classcore <https://github.com/emcd/python-classcore>`_ (`classcore <https://pypi.org/project/classcore/>`_ on PyPI)
|
|
384
|
+
|
|
385
|
+
🏭 A Python library package which provides **foundational class factories and decorators** for providing classes with attributes immutability and concealment and other custom behaviors.
|
|
386
|
+
* `python-detextive <https://github.com/emcd/python-detextive>`_ (`detextive <https://pypi.org/project/detextive/>`_ on PyPI)
|
|
387
|
+
|
|
388
|
+
🕵️ A Python library which provides consolidated text detection capabilities for reliable content analysis. Offers MIME type detection, character set detection, and line separator processing.
|
|
389
|
+
* `python-dynadoc <https://github.com/emcd/python-dynadoc>`_ (`dynadoc <https://pypi.org/project/dynadoc/>`_ on PyPI)
|
|
390
|
+
|
|
391
|
+
📝 A Python library package which bridges the gap between **rich annotations** and **automatic documentation generation** with configurable renderers and support for reusable fragments.
|
|
392
|
+
* `python-falsifier <https://github.com/emcd/python-falsifier>`_ (`falsifier <https://pypi.org/project/falsifier/>`_ on PyPI)
|
|
393
|
+
|
|
394
|
+
🎭 A very simple Python library package which provides a **base class for falsey objects** - objects that evaluate to ``False`` in boolean contexts.
|
|
395
|
+
* `python-frigid <https://github.com/emcd/python-frigid>`_ (`frigid <https://pypi.org/project/frigid/>`_ on PyPI)
|
|
396
|
+
|
|
397
|
+
🔒 A Python library package which provides **immutable data structures** - collections which cannot be modified after creation.
|
|
398
|
+
* `python-icecream-truck <https://github.com/emcd/python-icecream-truck>`_ (`icecream-truck <https://pypi.org/project/icecream-truck/>`_ on PyPI)
|
|
399
|
+
|
|
400
|
+
🍦 **Flavorful Debugging** - A Python library which enhances the powerful and well-known ``icecream`` package with flavored traces, configuration hierarchies, customized outputs, ready-made recipes, and more.
|
|
401
|
+
* `python-librovore <https://github.com/emcd/python-librovore>`_ (`librovore <https://pypi.org/project/librovore/>`_ on PyPI)
|
|
402
|
+
|
|
403
|
+
🐲 **Documentation Search Engine** - An intelligent documentation search and extraction tool that provides both a command-line interface for humans and an MCP (Model Context Protocol) server for AI agents. Search across Sphinx and MkDocs sites with fuzzy matching, extract clean markdown content, and integrate seamlessly with AI development workflows.
|
|
404
|
+
* `python-mimeogram <https://github.com/emcd/python-mimeogram>`_ (`mimeogram <https://pypi.org/project/mimeogram/>`_ on PyPI)
|
|
405
|
+
|
|
406
|
+
📨 A command-line tool for **exchanging collections of files with Large Language Models** - bundle multiple files into a single clipboard-ready document while preserving directory structure and metadata... good for code reviews, project sharing, and LLM interactions.
|