tinLogging
tinLogging is a versatile logging library for Python that provides a range of functionalities to enhance your application's logging capabilities
Installation
pip install tinLogging
Update
pip install --upgrade tinLogging
Quick start
from tinLogging import Logger, ConsoleLogger
logger = Logger(filename='log.txt', level='DEBUG', buffer_size=10, log_format='[%time] - %lvl | %text')
console_logger = ConsoleLogger(level='DEBUG', log_format='%time | %lvl | %text')
# Writing a log to a file 'log.txt'
logger.debug('This is a debug message')
# Log output to the console
console_logger.debug('This is a debug message')
console_logger.info('This is an info message')
console_logger.warning('This is a warning message')
console_logger.error('This is an error message')
This is what the color text output looks like in the console:
Logging to a file
Main functions
from tinLogging import Logger
logger = Logger(filename='log.txt', level='DEBUG', buffer_size=10, log_format='[%time] - %lvl | %text')
# Enabling automatic file rotation with zip archiving
logger.rotate_logs(max_megabytes_size=1, zip_compression=True, auto_rotate=True)
# Sending a log
logger.critical('This is a critical message')
# Creating a new log level with priority 3
logger.new_level(level_name='MyNewLevel', level_priority=3)
# Sending a log with a new level
logger.log('MyNewLevel', 'This is a MyNewLevel message')
# Deleting the old log level
logger.del_level('WARNING')
Additional functions
Export
logger.export_json(export_file='my_export_log.json')
logger.export_html(export_file='my_new_export_log.html')
Search and filtering
# Text search
search = logger.search_logs('message')
# Filtering by level
filter_logs = logger.filter_logs('CRITICAL')
Statistics
logger.log_stats(files_name='log.txt')
Archiving
logger.archive_logs(archive_name='my_zip_log.zip')
Checking for acceptable file size
logger.monitor_log_size(max_megabytes_size=8)
# Returns True if it exceeds the specified size
Buffer
# buffer_size - buffer size for optimizing I/O requests
logger = Logger(filename='log.txt', level='DEBUG', buffer_size=10, log_format='[%time] - %lvl | %text')
# Recording the remaining logs in the buffer
logger.close()
Logging to a Console
Logging into the console will allow you to display colored logs to facilitate the search for the necessary logging levels. But do not forget that after restarting the interpreter, the console is cleared
from tinLogging import ConsoleLogger
# You can customize the colors to suit your taste, but by default there are always the most suitable colors
logger = ConsoleLogger(level='DEBUG', log_format='%time | %lvl | %text', debug_color='standard', info_color='green')
# Creating a new log level
logger.new_level('HTTP', 4)
# Logging with the HTTP level highlighted in green
logger.log(level='HTTP', message='Code 200 - the site is working', color='green')
Contributing
We welcome contributions to the tinLogging project! If you have any bug reports, feature requests, or pull requests, please feel free to submit them on our GitHub repository
License
tinLogging is licensed under the MIT License. See the LICENSE file for more information
Metadata
Release files for tinLogging 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tinlogging-0.0.3.tar.gz | 7.9 kB | Without provenance | Details for tinlogging-0.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tinLogging-0.0.3-py3-none-any.whl | Python 3 | none | any | Details for tinLogging-0.0.3-py3-none-any.whl |
Total release size: 14.4 kB
Release files / tinlogging-0.0.3.tar.gz
| Download URL | tinlogging-0.0.3.tar.gz |
|---|---|
| Size | 7.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7218786df6d4db9a19d88ba5e15bd7c1de955b7f16ba0a16eb45ef36e8ec8269
|
|
BLAKE2b-256 checksum How to use checksums |
2a8708a83f0fd8db75fa6019c7624ac3651a54fe26bfa6d25d40d17740847f7b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.4
|
Release files / tinLogging-0.0.3-py3-none-any.whl
| Download URL | tinLogging-0.0.3-py3-none-any.whl |
|---|---|
| Size | 6.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cda3009b9a19a06aba1abb7d9c4e7678e0edd9c18834010af2036eb46349a7a8
|
|
BLAKE2b-256 checksum How to use checksums |
861c81e983291fd7ef5bc334034120d8ba3e851e5f6a0e267d6be7679ee6c451
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.4
|
Security for tinLogging 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.