A custom logging package
Project description
Logged.py
A custom logging package with advanced features including color-coded console output, log rotation, and compression.
Installation
To install the package you can run this command in your command prompt or powershell.
pip install logged
Usage
Importing the Package
import logged
Creating a Logger
Create a Logger instance with the desired output type and format.
logger = logger.Logger(output_type='console', format='<bold><gray>/d</gray> <type>/t</type></bold> /m')
output_type: Specify "console" for console output or "file" for file output.
format: Define the log message format using custom tags (e.g., /d for date, /t for type, /m for message).
file: If you chose output type as "file" this is a required parameter which must include the log file path.
Logging Messages
You can use different methods to log messages at various levels:
logger.trace("This is a trace message.")
logger.debug("This is a debug message.")
logger.info("This is an info message.")
logger.warn("This is a warning message.")
logger.error("This is an error message.")
logger.fatal("This is a fatal message.")
logger.all("This is a message for all levels.")
Features
- Customizable Formatting: Use ANSI color codes and custom tags in log messages.
- Log Rotation with Compression: Automatically rotates log files and compresses old logs into ZIP archives.
- Flexible Output Options: Choose between console and file output.
API Reference
Logger A class for logging messages.
Constructor:
output_type: "console" or "file". Default is "console". format: Log message format. Default is "/d /t /m". <str?>file: File path for file output.
Methods:
trace(message: str): Logs a trace message.
debug(message: str): Logs a debug message.
info(message: str): Logs an info message.
warn(message: str): Logs a warning message.
error(message: str): Logs an error message.
fatal(message: str): Logs a fatal message.
all(message: str): Logs a message for all levels.
Example:
import logger
# Initialize logger
logger = logger.Logger(output_type='file', format='<bold><gray>/d</gray> <type>/t</type></bold> /m', file='logfile.txt')
# Log messages
logger.info("This is an info message.")
logger.error("This is an error message.")
License
This package is licensed under the MIT License. See the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for logged_hypixeloffical-0.2.tar.gz
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 | f8b1bdc20e35f5d3852e5a40311470ed80cc3ba1da09d5dde7defb149f9e439e |
|
| MD5 | aa32e697a0f6fd6ab54ee8c8d2a08792 |
|
| BLAKE2b-256 | 48b83643440083b41cee991e2eabaee153473339b69dc7f9ef9db5b4be3bbf2e |
Hashes for logged_hypixeloffical-0.2-py3-none-any.whl
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 | 32379b139dec6760d997108fe73ad386320be757a445722442c341f5b07b9c1f |
|
| MD5 | 0ea7a56d5e980d2995e5938a3a466884 |
|
| BLAKE2b-256 | 8527c5a9c965f315b494d84925413f5f9d70142e33e0cba031daa0b6c7547666 |