This module provides a configurable logging setup for Python applications. It supports logging to console, file, syslog (for Linux and macOS), and Windows Event Log. The user can enable or disable each logging method as needed.
Project description
mlogconfig.py
This module provides a configurable logging setup for Python applications. It supports logging to console, file, syslog (for Linux and macOS), and Windows Event Log. The user can enable or disable each logging method as needed.
Features
- Logging to console, file, syslog, and Windows Event Log
- Enable or disable each logging method as needed
- Easy setup and configuration
Requirements
- Python 3.9 or higher
For Windows Event Log support, the following packages are required:
- pywin32
Install the required packages by running:
pip install pywin32
Usage
Here is a basic example of using MLogConfig to set up logging for your application:
from mlogconfig import setup_logging
import logging
# Set up logging
setup_logging(
log_file_path="logs/app.log",
error_log_file_path="logs/app_error.log",
console_logging=True,
syslog_logging=True,
windows_event_logging=True,
log_level=logging.DEBUG,
)
# Use logging in your application
logging.info("This is an info log message.")
logging.error("This is an error log message.")
Customization
To customize the logging configuration, modify the arguments passed to the setup_logging function. For example:
log_file_path: Path to the log fileerror_log_file_path: Path to the error log fileconsole_logging: Set toTrueto enable console logging,Falseotherwisesyslog_logging: Set toTrueto enable syslog logging (Linux and macOS only),Falseotherwisewindows_event_logging: Set toTrueto enable Windows Event Log logging,Falseotherwiselog_level: Set the logging level (e.g.,logging.DEBUG,logging.INFO,logging.WARNING,logging.ERROR,logging.CRITICAL)
Contributing
Contributions are welcome! Please read the contributing guidelines before submitting pull requests or opening issues.
License
MLogConfig is licensed under the MIT 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 mlogconfig-0.2.5.tar.gz.
File metadata
- Download URL: mlogconfig-0.2.5.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.10.6 Linux/5.15.0-1038-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
24f3a887684d1a5bc6643f4b42bf4db7b56d3356df1565cbe8ec26e4f9050514
|
|
| MD5 |
e60c0aff8b8878cf91d896783ac27fb2
|
|
| BLAKE2b-256 |
5a1323c3e9a1c1a9d2b9313b681dd4af28620c940101849e60486f850d51ad02
|
File details
Details for the file mlogconfig-0.2.5-py3-none-any.whl.
File metadata
- Download URL: mlogconfig-0.2.5-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.10.6 Linux/5.15.0-1038-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
db398281f298f857a8f011511ff67298b8a60d1a7f950f364a1006bf3966f3cb
|
|
| MD5 |
418821ed78a29453a35a78ca545214f0
|
|
| BLAKE2b-256 |
e185e98162a523c7b4d605b43ac3def69243f195db42baea1afad525d7f543b3
|