Custom Logger: Enhanced Logging for Your Python Applications
Introduction
This Python package provides a robust and customizable logger that simplifies the process of recording messages and events in your applications. It leverages the power of the colorlog library to enhance readability and debugging capabilities.
Key Features
- Flexible Log Levels: Supports standard logging levels (
DEBUG,INFO,WARNING,ERROR, andCRITICAL) to categorize messages based on severity. - Colorized Output: Leverages
colorlogto display log messages in distinct colors, improving visual clarity. - File and Console Logging: Logs messages to a specified file and optionally to the console for immediate feedback.
- Customizable Formatting: Control the appearance of log messages using formatters for both file and console output.
- Dynamic Console Logging: Enable or disable console logging at runtime to manage verbosity during development.
- Handler Management: Add, remove, or adjust logging handlers to tailor logging behavior.
- Default Loggers: Provides convenient wrappers for standard logging methods (
debug,info,warning,error,critical, andexception). - Session Logging: Decorator function
log_sessionto enclose a block of code with logging messages for session tracking. - Log File Reading: Utility function
read_log_fileto conveniently read and display the contents of the log file. - Log File Clearing: Optional
clear_log_filemethod to clear existing log data.
Installation
From pypi.org
To install the ultra_logger package from PyPI (the Python Package Index), use the following command in your terminal:
pip install ultra_logger
Usage
-
Import the Logger Class:
from ultra_logger import Logger
-
Create a Logger Instance:
logger = Logger(log_name='my_logger', log_file='app.log', log_to_console=True)
log_name: A descriptive name for your logger (e.g., 'my_logger').log_file: The path to the log file where messages will be saved.log_to_console(optional, defaults toTrue): Whether to log messages to the console.
-
Log Messages:
logger.log_message('info', 'This is an informative message.') logger.warning('This is a warning message.') logger.error('This is an error message.') logger.critical('This is a critical message.')
-
Default Loggers:
logger.info('This is a general message.') logger.warning('This requires attention.') logger.exception('An exception occurred!', exc_info=True) # Optional exception info
-
Session Logging:
@logger.log_session def my_function(): # Your code here logger.info('Processing completed.')
The
log_sessiondecorator automatically logs the start and end of the function execution. -
Read Log File:
logger.read_log_file()
-
Clear Log File (optional):
logger.clear_log_file() # Use with caution
Advanced Usage
-
Dynamic Console Logging:
logger.disable_console_logging() # Disable console logging logger.enable_console_logging() # Re-enable console logging
-
Handler Management:
Refer to the source code for details on adding, removing, or modifying logging handlers.
Customization
For advanced customization, consult the source code to modify formatting options for file and console output or create custom handlers.
Contributing
We welcome contributions to improve this logger. Feel free to submit pull requests on GitHub!
License
This project is licensed under the MIT License. See the LICENSE file for details.
Metadata
Release files for ultra-logger 0.1.2
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 |
|---|---|---|---|---|
| ultra_logger-0.1.2.tar.gz | 5.8 kB | Without provenance | Details for ultra_logger-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ultra_logger-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for ultra_logger-0.1.2-py3-none-any.whl |
Total release size: 11.4 kB
Release files / ultra_logger-0.1.2.tar.gz
| Download URL | ultra_logger-0.1.2.tar.gz |
|---|---|
| Size | 5.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c7852b9917fd8087bb75282cfe09a97de82b8f7a8c7b18e7f14eb707ae91c278
|
|
BLAKE2b-256 checksum How to use checksums |
4479fbc557056981d71827e213a53789fc6118e311848c5a6a62b50e95b7757f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.12.2
|
Release files / ultra_logger-0.1.2-py3-none-any.whl
| Download URL | ultra_logger-0.1.2-py3-none-any.whl |
|---|---|
| Size | 5.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8e84b3195a08d0213c18ac32851cb789f70433b83d476e13431900d71ed46322
|
|
BLAKE2b-256 checksum How to use checksums |
b40882a598cb188739753121f52ac1ab27f277020bbc5e40e13673b29490fa6b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.12.2
|
Security for ultra-logger 0.1.2
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.