loggio 2025.12.13__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.
@@ -0,0 +1,216 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ # Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ # poetry.lock
109
+ # poetry.toml
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
114
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
115
+ # pdm.lock
116
+ # pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # pixi
121
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
122
+ # pixi.lock
123
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
124
+ # in the .venv directory. It is recommended not to include this directory in version control.
125
+ .pixi
126
+
127
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
128
+ __pypackages__/
129
+
130
+ # Celery stuff
131
+ celerybeat-schedule
132
+ celerybeat.pid
133
+
134
+ # Redis
135
+ *.rdb
136
+ *.aof
137
+ *.pid
138
+
139
+ # RabbitMQ
140
+ mnesia/
141
+ rabbitmq/
142
+ rabbitmq-data/
143
+
144
+ # ActiveMQ
145
+ activemq-data/
146
+
147
+ # SageMath parsed files
148
+ *.sage.py
149
+
150
+ # Environments
151
+ .env
152
+ .envrc
153
+ .venv
154
+ env/
155
+ venv/
156
+ ENV/
157
+ env.bak/
158
+ venv.bak/
159
+
160
+ # Spyder project settings
161
+ .spyderproject
162
+ .spyproject
163
+
164
+ # Rope project settings
165
+ .ropeproject
166
+
167
+ # mkdocs documentation
168
+ /site
169
+
170
+ # mypy
171
+ .mypy_cache/
172
+ .dmypy.json
173
+ dmypy.json
174
+
175
+ # Pyre type checker
176
+ .pyre/
177
+
178
+ # pytype static type analyzer
179
+ .pytype/
180
+
181
+ # Cython debug symbols
182
+ cython_debug/
183
+
184
+ # PyCharm
185
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
186
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
187
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
188
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
189
+ # .idea/
190
+
191
+ # Abstra
192
+ # Abstra is an AI-powered process automation framework.
193
+ # Ignore directories containing user credentials, local state, and settings.
194
+ # Learn more at https://abstra.io/docs
195
+ .abstra/
196
+
197
+ # Visual Studio Code
198
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
199
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
200
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
201
+ # you could uncomment the following to ignore the entire vscode folder
202
+ # .vscode/
203
+
204
+ # Ruff stuff:
205
+ .ruff_cache/
206
+
207
+ # PyPI configuration file
208
+ .pypirc
209
+
210
+ # Marimo
211
+ marimo/_static/
212
+ marimo/_lsp/
213
+ __marimo__/
214
+
215
+ # Streamlit
216
+ .streamlit/secrets.toml
@@ -0,0 +1,121 @@
1
+ Creative Commons Legal Code
2
+
3
+ CC0 1.0 Universal
4
+
5
+ CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
6
+ LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
7
+ ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
8
+ INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
9
+ REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
10
+ PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
11
+ THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
12
+ HEREUNDER.
13
+
14
+ Statement of Purpose
15
+
16
+ The laws of most jurisdictions throughout the world automatically confer
17
+ exclusive Copyright and Related Rights (defined below) upon the creator
18
+ and subsequent owner(s) (each and all, an "owner") of an original work of
19
+ authorship and/or a database (each, a "Work").
20
+
21
+ Certain owners wish to permanently relinquish those rights to a Work for
22
+ the purpose of contributing to a commons of creative, cultural and
23
+ scientific works ("Commons") that the public can reliably and without fear
24
+ of later claims of infringement build upon, modify, incorporate in other
25
+ works, reuse and redistribute as freely as possible in any form whatsoever
26
+ and for any purposes, including without limitation commercial purposes.
27
+ These owners may contribute to the Commons to promote the ideal of a free
28
+ culture and the further production of creative, cultural and scientific
29
+ works, or to gain reputation or greater distribution for their Work in
30
+ part through the use and efforts of others.
31
+
32
+ For these and/or other purposes and motivations, and without any
33
+ expectation of additional consideration or compensation, the person
34
+ associating CC0 with a Work (the "Affirmer"), to the extent that he or she
35
+ is an owner of Copyright and Related Rights in the Work, voluntarily
36
+ elects to apply CC0 to the Work and publicly distribute the Work under its
37
+ terms, with knowledge of his or her Copyright and Related Rights in the
38
+ Work and the meaning and intended legal effect of CC0 on those rights.
39
+
40
+ 1. Copyright and Related Rights. A Work made available under CC0 may be
41
+ protected by copyright and related or neighboring rights ("Copyright and
42
+ Related Rights"). Copyright and Related Rights include, but are not
43
+ limited to, the following:
44
+
45
+ i. the right to reproduce, adapt, distribute, perform, display,
46
+ communicate, and translate a Work;
47
+ ii. moral rights retained by the original author(s) and/or performer(s);
48
+ iii. publicity and privacy rights pertaining to a person's image or
49
+ likeness depicted in a Work;
50
+ iv. rights protecting against unfair competition in regards to a Work,
51
+ subject to the limitations in paragraph 4(a), below;
52
+ v. rights protecting the extraction, dissemination, use and reuse of data
53
+ in a Work;
54
+ vi. database rights (such as those arising under Directive 96/9/EC of the
55
+ European Parliament and of the Council of 11 March 1996 on the legal
56
+ protection of databases, and under any national implementation
57
+ thereof, including any amended or successor version of such
58
+ directive); and
59
+ vii. other similar, equivalent or corresponding rights throughout the
60
+ world based on applicable law or treaty, and any national
61
+ implementations thereof.
62
+
63
+ 2. Waiver. To the greatest extent permitted by, but not in contravention
64
+ of, applicable law, Affirmer hereby overtly, fully, permanently,
65
+ irrevocably and unconditionally waives, abandons, and surrenders all of
66
+ Affirmer's Copyright and Related Rights and associated claims and causes
67
+ of action, whether now known or unknown (including existing as well as
68
+ future claims and causes of action), in the Work (i) in all territories
69
+ worldwide, (ii) for the maximum duration provided by applicable law or
70
+ treaty (including future time extensions), (iii) in any current or future
71
+ medium and for any number of copies, and (iv) for any purpose whatsoever,
72
+ including without limitation commercial, advertising or promotional
73
+ purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
74
+ member of the public at large and to the detriment of Affirmer's heirs and
75
+ successors, fully intending that such Waiver shall not be subject to
76
+ revocation, rescission, cancellation, termination, or any other legal or
77
+ equitable action to disrupt the quiet enjoyment of the Work by the public
78
+ as contemplated by Affirmer's express Statement of Purpose.
79
+
80
+ 3. Public License Fallback. Should any part of the Waiver for any reason
81
+ be judged legally invalid or ineffective under applicable law, then the
82
+ Waiver shall be preserved to the maximum extent permitted taking into
83
+ account Affirmer's express Statement of Purpose. In addition, to the
84
+ extent the Waiver is so judged Affirmer hereby grants to each affected
85
+ person a royalty-free, non transferable, non sublicensable, non exclusive,
86
+ irrevocable and unconditional license to exercise Affirmer's Copyright and
87
+ Related Rights in the Work (i) in all territories worldwide, (ii) for the
88
+ maximum duration provided by applicable law or treaty (including future
89
+ time extensions), (iii) in any current or future medium and for any number
90
+ of copies, and (iv) for any purpose whatsoever, including without
91
+ limitation commercial, advertising or promotional purposes (the
92
+ "License"). The License shall be deemed effective as of the date CC0 was
93
+ applied by Affirmer to the Work. Should any part of the License for any
94
+ reason be judged legally invalid or ineffective under applicable law, such
95
+ partial invalidity or ineffectiveness shall not invalidate the remainder
96
+ of the License, and in such case Affirmer hereby affirms that he or she
97
+ will not (i) exercise any of his or her remaining Copyright and Related
98
+ Rights in the Work or (ii) assert any associated claims and causes of
99
+ action with respect to the Work, in either case contrary to Affirmer's
100
+ express Statement of Purpose.
101
+
102
+ 4. Limitations and Disclaimers.
103
+
104
+ a. No trademark or patent rights held by Affirmer are waived, abandoned,
105
+ surrendered, licensed or otherwise affected by this document.
106
+ b. Affirmer offers the Work as-is and makes no representations or
107
+ warranties of any kind concerning the Work, express, implied,
108
+ statutory or otherwise, including without limitation warranties of
109
+ title, merchantability, fitness for a particular purpose, non
110
+ infringement, or the absence of latent or other defects, accuracy, or
111
+ the present or absence of errors, whether or not discoverable, all to
112
+ the greatest extent permissible under applicable law.
113
+ c. Affirmer disclaims responsibility for clearing rights of other persons
114
+ that may apply to the Work or any use thereof, including without
115
+ limitation any person's Copyright and Related Rights in the Work.
116
+ Further, Affirmer disclaims responsibility for obtaining any necessary
117
+ consents, permissions or other rights required for any use of the
118
+ Work.
119
+ d. Affirmer understands and acknowledges that Creative Commons is not a
120
+ party to this document and has no duty or obligation with respect to
121
+ this CC0 or use of the Work.
@@ -0,0 +1,286 @@
1
+ Metadata-Version: 2.4
2
+ Name: loggio
3
+ Version: 2025.12.13
4
+ Summary: Comprehensive logging utility with colored output, user context tracking, and automatic truncation.
5
+ Project-URL: Homepage, https://github.com/xcollantes/loggio
6
+ Project-URL: Repository, https://github.com/xcollantes/loggio
7
+ Project-URL: Issues, https://github.com/xcollantes/loggio/issues
8
+ Author-email: Xavier Collantes <collantes.xavier@gmail.com>
9
+ Maintainer-email: Xavier Collantes <collantes.xavier@gmail.com>
10
+ License-Expression: CC0-1.0
11
+ License-File: LICENSE
12
+ Keywords: automatic truncation,colored,debugging,enhanced,logger,logging,terminal,user context
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Environment :: Console
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: License :: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Topic :: System :: Logging
22
+ Requires-Python: >=3.10
23
+ Description-Content-Type: text/markdown
24
+
25
+ # Enhanced Logger Loggio
26
+
27
+ A comprehensive logging utility for project that provides:
28
+
29
+ - Timestamp information in logs
30
+ - User ID tracking for authenticated requests
31
+ - File name and line number of the log call
32
+ - Clean and consistent log formatting
33
+ - Multiple usage patterns for different scenarios
34
+
35
+ ## Features
36
+
37
+ - **Contextual Information**: Every log includes timestamp, log level, file
38
+ name, and line number
39
+ - **Authentication Awareness**: Can include user ID in logs when available
40
+ - **Format String Support**: Supports Python's standard string formatting with
41
+ %s, %d, etc.
42
+ - **Flexible Configuration**: Configurable output destination (terminal and/or
43
+ file)
44
+ - **Consistent API**: Familiar logging methods (debug, info, warning, error,
45
+ critical)
46
+
47
+ ## Installation
48
+
49
+ ### From PyPI (Recommended)
50
+
51
+ ```bash
52
+ pip install loggio
53
+ ```
54
+
55
+ Then import in your code:
56
+
57
+ ```python
58
+ from loggio import get_logger
59
+ ```
60
+
61
+ ### From Source
62
+
63
+ To use standalone, use as a fork.
64
+
65
+ To get updates, use as a submodule.
66
+
67
+ #### As standalone
68
+
69
+ Go to inside your project.
70
+
71
+ Clone the repository:
72
+
73
+ ```bash
74
+ git clone https://github.com/xcollantes/loggio loggio
75
+ ```
76
+
77
+ #### As submodule to existing repo
78
+
79
+ Go to where you want to dependency.
80
+
81
+ Clone the repository as submodule:
82
+
83
+ `loggio` must be maintained since Python import statements don't work
84
+ work hyphens.
85
+
86
+ ```bash
87
+ git submodule add https://github.com/xcollantes/loggio loggio
88
+ ```
89
+
90
+ #### Cloning your project that contains submodules
91
+
92
+ Clone the repository with submodules:
93
+
94
+ ```bash
95
+ git clone --recursive https://github.com/xcollantes/my-project-with-submodules
96
+ ```
97
+
98
+ Remember `--recursive` for submodules.
99
+
100
+ If you clone without --recursive:
101
+
102
+ ```bash
103
+ git submodule update --init --recursive
104
+ ```
105
+
106
+ #### Create and Activate Virtual Environment
107
+
108
+ ```bash
109
+ # Create virtual environment.
110
+ python3 -m venv env
111
+
112
+ # Activate virtual environment.
113
+ # On macOS/Linux:
114
+ source env/bin/activate
115
+
116
+ # On Windows:
117
+ # venv\Scripts\activate
118
+ ```
119
+
120
+ #### Install Dependencies
121
+
122
+ ```bash
123
+ pip install -r requirements.txt
124
+ ```
125
+
126
+ #### Environment Configuration
127
+
128
+ Create a `.env` file in the project root with the required environment
129
+ variables. The following variables are used by the application:
130
+
131
+ #### Running the Application
132
+
133
+ #### Basic Usage
134
+
135
+ ```bash
136
+ python3 main.py
137
+ ```
138
+
139
+ ## Usage Examples
140
+
141
+ ### Basic Usage (No Authentication)
142
+
143
+ For utility functions, background tasks, or non-authenticated endpoints:
144
+
145
+ ```python
146
+ from loggio import get_logger
147
+
148
+ # Create a logger instance.
149
+ logger = get_logger(name="module.name")
150
+
151
+ # Log messages with different levels
152
+ logger.debug("This is a debug message.")
153
+ logger.info("This is an info message.")
154
+ logger.warning("This is a warning message.")
155
+ ```
156
+
157
+ Output example:
158
+
159
+ ```
160
+ INFO:2023-05-01 14:30:45:example.py:24:This is an info message.
161
+ ```
162
+
163
+ ### Using Format Strings
164
+
165
+ The logger supports Python's standard string formatting:
166
+
167
+ ```python
168
+ from loggio import get_logger
169
+
170
+ logger = get_logger(name="module.formatter")
171
+
172
+ # Using format strings
173
+ item_id = "A123"
174
+ priority = 2
175
+ logger.info("Processing item %s with priority %d", item_id, priority)
176
+ ```
177
+
178
+ Output example:
179
+
180
+ ```
181
+ INFO:2023-05-01 14:31:22:formatter.py:15:Processing item A123 with priority 2
182
+ ```
183
+
184
+ ### Usage with User Context
185
+
186
+ When you have authentication info:
187
+
188
+ ```python
189
+ from loggio import get_logger
190
+
191
+ # Create a logger instance.
192
+ logger = get_logger(name="module.auth")
193
+
194
+ # Get user info from somewhere (e.g., decoded token)
195
+ user_info = {"uid": "user123", "email": "user@example.com"}
196
+
197
+ # Log with user context
198
+ logger.info("User performed an action.", user_context=user_info)
199
+ ```
200
+
201
+ Output example:
202
+
203
+ ```
204
+ INFO:2023-05-01 14:32:10:auth_service.py:45:user123: User performed an action.
205
+ ```
206
+
207
+ ### Format Strings with User Context
208
+
209
+ Combining format strings with user context:
210
+
211
+ ```python
212
+ logger.info("Processing file %s for action %s", filename, action, user_context=user_info)
213
+ ```
214
+
215
+ ### Error Handling with Logging
216
+
217
+ ```python
218
+ try:
219
+ # Some risky operation
220
+ result = perform_risky_operation()
221
+ logger.info(f"Operation successful: {result}")
222
+ except Exception as e:
223
+ logger.error(f"Operation failed: {str(e)}")
224
+ # Handle or re-raise as appropriate
225
+ ```
226
+
227
+ ## Configuration Options
228
+
229
+ When creating a logger instance, you can configure:
230
+
231
+ - `name`: Logger name for filtering and organization (e.g., "api.auth",
232
+ "service.processor")
233
+ - `level`: Minimum log level (DEBUG, INFO, WARNING, ERROR, CRITICAL) - defaults
234
+ to "INFO"
235
+ - `fileout`: Whether to write logs to a file (default: False)
236
+ - `terminal`: Whether to output logs to the terminal/console (default: True)
237
+ - `fileout_path`: Path for log file if `fileout` is True (default:
238
+ "logs/app.log")
239
+
240
+ Example with custom configuration:
241
+
242
+ ```python
243
+ logger = get_logger(
244
+ name="batch.processor",
245
+ level="DEBUG",
246
+ fileout=True,
247
+ fileout_path="logs/batch_processor.log",
248
+ terminal=True
249
+ )
250
+ ```
251
+
252
+ ## Log Format
253
+
254
+ The logger produces logs in the following format:
255
+
256
+ ```
257
+ LEVEL:TIMESTAMP:FILENAME:LINE_NUMBER:MESSAGE
258
+ ```
259
+
260
+ For example:
261
+
262
+ ```
263
+ INFO:2023-05-01 14:35:22:auth_routes.py:28:user123: Processing protected resource request
264
+ ```
265
+
266
+ ## Best Practices
267
+
268
+ 1. Use a hierarchical naming scheme for loggers (e.g., `api.auth`,
269
+ `service.processor`)
270
+ 2. Include meaningful context in log messages
271
+ 3. Use the appropriate log level for different scenarios:
272
+ - DEBUG: Detailed information for debugging
273
+ - INFO: Confirmation that things are working as expected
274
+ - WARNING: Something unexpected happened, but the application can continue
275
+ - ERROR: A more serious problem that prevented a function from working
276
+ - CRITICAL: A very serious error that might prevent the program from
277
+ continuing
278
+ 4. Include user context when available for better traceability
279
+ 5. Include error details when logging exceptions
280
+
281
+ ## Implementation Details
282
+
283
+ The Enhanced Logger builds on Python's built-in logging module with custom
284
+ formatting and context handling. It uses `stacklevel=2` to ensure the correct
285
+ file and line number are recorded in the logs rather than showing the logger
286
+ implementation file itself.