A highly customizable logging library for Python.
Project description
Logery
A highly customizable logging library for Python.
Installation
Install the package using pip:
pip install logery
Quick Start
To get started, you need to generate the configuration files. You can do this by running the following command in your terminal:
logery --dotenv .env --json logging.conf.json
This will create two files:
.env: Contains environment variables for configuring the logger.logging.conf.json: A JSON file with the detailed logging configuration.
Now you can start using the logger in your Python code:
from logery import get_logger
logger = get_logger("my_app")
logger.info("This is an informational message.")
logger.warning("This is a warning message.")
logger.error("This is an error message.")
Customization
You can customize the logging configuration by editing the logging.conf.json file. This file allows you to change formatters, handlers, filters, and more.
For example, you can add a new handler to send logs to a different file:
{
...
"handlers": {
...
"my_new_handler": {
"class": "logging.FileHandler",
"formatter": "file",
"filename": "logs/my_app.log"
}
},
"root": {
"handlers": ["console", "queue", "my_new_handler"]
}
}
You can also adjust the log levels in the .env file:
# .env
DEFAULT_LOGGER_LEVEL='INFO'
Advanced Usage
For more advanced customization, you can directly interact with the underlying logging library components provided by logery.
Formatters
JSONLogFormatter: Formats log records as JSON.
Filters
MaxLevelFilter: Filters log records based on a maximum log level.
Handlers
MyRichHandler: Arich-based handler for beautiful console output.
You can find more details on how to use these components in the logging.conf.json file.
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 logery-0.0.2.tar.gz.
File metadata
- Download URL: logery-0.0.2.tar.gz
- Upload date:
- Size: 8.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
225018c3cea93c15c88a2dfd70b75f073eb63f026d930844f18fbbf4fd193485
|
|
| MD5 |
e09149220d94a7aefd567a6d525f676b
|
|
| BLAKE2b-256 |
37c3aca2e7f9b5abee98a884330a1b8b16278367c2a2a45bf9e714004619e780
|
File details
Details for the file logery-0.0.2-py3-none-any.whl.
File metadata
- Download URL: logery-0.0.2-py3-none-any.whl
- Upload date:
- Size: 9.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8e9de7fb370af6d776c236ce963caf5f42c70c4f2f4ad87a3125d5fc15cbde94
|
|
| MD5 |
5d7c0c65c9c8070e85b5f637818e8fbe
|
|
| BLAKE2b-256 |
f04b3ea4c8da5146c4e1cd4ffa9e155a2bae997d70a4dbbcc343e7c58808c4fc
|