A Python package to set up structured logging for your applications.
Project description
mlpLogger
mlpLogger is a Python package designed to simplify structured logging for your applications. It provides easy-to-use methods to create daily log files, manage log handlers, and include structured metadata in your logs.
📦 Installation
Install the latest version from PyPI using:
pip install mlpLogger
🚀 Usage
Here’s a quick example of how to use mlpLogger in your project:
from mlpLogger import MLPLogger
# Initialize the logger
logger = MLPLogger()
# Print the current log file name
print(f"Current log file: {logger.logfilename}")
# Log a simple info message
logger.logger.info("This is a simple info log message.")
# Change the log file name dynamically
logger.logfilename = "custom_mlpLogger.log"
print(f"Updated log file: {logger.logfilename}")
# Log a message to the new file
logger.logger.info("This is a log message in the new file.")
# Log a structured 'success' outcome
log_extras = logger.logSuccess({})
print(f"Logged success with extras: {log_extras}")
🛠️ Features
✅ Automatic Daily Log Files
✅ Structured Logging with ECS Formatter
✅ Dynamic Log File Switching
✅ Helper Methods for Structured Logging (e.g., logSuccess)
✅ Fully Configurable for Use in Any Project
🔧 Methods
-
MLPLogger.logfilename- Getter: Prints and returns the current log filename.
- Setter: Dynamically updates the log file and reconfigures the logger.
-
MLPLogger.logSuccess(logExtrasIn)- Logs a structured “success” message and returns the updated dictionary of log extras.
-
MLPLogger.createDailyLogfileName(logfile)- Creates a daily log filename based on UTC date.
-
MLPLogger.createScriptRunID(scriptname)- Generates a unique ID for script runs.
📂 Project Structure
mlpLogger/
├── mlpLogger/ # Main package module
│ ├── __init__.py
│ └── mlpLogger.py
├── tests/ # Unit tests
├── LICENSE
├── README.md
├── setup.py
├── pyproject.toml
└── example_usage.py # Demonstration script
⚖️ License
This project is licensed under the MIT License. See the LICENSE file for details.
👤 Author
Michael Baskaran
Email: mbas@caasco.ca
🙏 Contributing
Contributions are welcome! Please fork this repository and submit a pull request with your improvements.
mlpLogger — making structured logging simpler and more reliable for your Python applications!
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
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 mlplogger-0.1.0.tar.gz.
File metadata
- Download URL: mlplogger-0.1.0.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cb135fe316443a299f9da479d5102713ad76fd68044c95ebbd835ffd36c17291
|
|
| MD5 |
6f867426c1f0e00ebdc8de5134aebc11
|
|
| BLAKE2b-256 |
7519fdfa8ae5895b4d1e216867126ee62cab82416bc90995ec5e02ced020336f
|
File details
Details for the file mlplogger-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mlplogger-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4445551680a233898b0f0c95ca50abce8ea5ff47e106408221332ca3a8855105
|
|
| MD5 |
b3019077cc04f511c6d555caa5b597df
|
|
| BLAKE2b-256 |
5a0304f05aed05f93f9f94622d4577863604f6bbd6329718a423436645af9599
|