No project description provided
Project description
Level Logger
Level Logger is a Python class that provides a simple and customizable logging system with colored output. It allows you to log messages at different levels of severity and customize the appearance of your log messages.
Features
- Six logging levels: DEBUG, INFO, ATTENTION, WARNING, ERROR, and CRITICAL
- Colored output for easy visual distinction between log levels
- Customizable message header
- Ability to enable/disable logging
- Timestamp included with each log message
Installation
To use the Level Logger, run pip install levellogger
Usage
Here's a basic example of how to use the Logger:
from levellogger import Logger
# Initialize the logger
logger = Logger(level="DEBUG", header="MyApp")
# Log messages at different levels
logger.debug("This is a debug message")
logger.info("This is an info message")
logger.attention("This is an attention message")
logger.warning("This is a warning message")
logger.error("This is an error message")
logger.critical("This is a critical message")
API Reference
Constructor
Logger(level: Union[int, str] = "INFO", header: str = None)
level: The initial log level. Can be a string ("DEBUG", "INFO", "ATTENTION", "WARNING", "ERROR", "CRITICAL") or an integer (0-5). Defaults to "INFO".header: An optional message header to be included in all log messages.
Methods
set_message_header(header: str): Set the message header.enable_logging(): Enable logging.disable_logging(): Disable logging.debug(message: str): Log a debug message.info(message: str): Log an info message.attention(message: str): Log an attention message.warning(message: str): Log a warning message.error(message: str): Log an error message.critical(message: str): Log a critical message.set_level(level: int): Set the log level.
Example
logger = Logger()
logger.set_level(logger.DEBUG)
logger.set_message_header("Test Logger")
logger.debug("This is a debug message")
logger.info("This is an info message")
logger.attention("This is an attention message")
logger.warning("This is a warning message")
logger.error("This is an error message")
logger.critical("This is a critical message")
This will output colored log messages with timestamps and the specified header.
License
This project is open-source and available under the GNU 3 License.
Project details
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file levellogger-0.2.5.tar.gz.
File metadata
- Download URL: levellogger-0.2.5.tar.gz
- Upload date:
- Size: 15.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4775f4060bc3eb1da76919912c6acd6ef0e755b8d84170cf99459f65adc2d531
|
|
| MD5 |
395c8de2e1d5bb158bfc241091e8331a
|
|
| BLAKE2b-256 |
9b8413c18ede15f917aa8ad873ce26c042556dcc04be2a4c73d8c37097007216
|
File details
Details for the file levellogger-0.2.5-py3-none-any.whl.
File metadata
- Download URL: levellogger-0.2.5-py3-none-any.whl
- Upload date:
- Size: 18.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
88eab200aeacc31903b5fb38fb96da46f0750d8b15912d2ccd0db70b9d5d49f5
|
|
| MD5 |
8922858329c5911ab97cfc5bbb2e62f9
|
|
| BLAKE2b-256 |
02e485446a19f19070a8294acc415e4efceaa3630e2abdd1745944524a0cdc67
|