# RsLogMod
**RsLogMod** is a flexible and powerful Python logging module designed to manage log files with features such as log rotation, customizable paths, and various log levels. It is easy to use yet offers extensive customization options.
## Table of Contents
- [Installation](#installation)
- [Getting Started](#getting-started)
- [Default Behavior](#default-behavior)
- [Log Levels & Prefixes](#log-levels--prefixes)
- [Customization](#customization)
- [Set Log Folder Path](#set-log-folder-path)
- [Set Archive Folder Path](#set-archive-folder-path)
- [Set Maximum Log Size](#set-maximum-log-size)
- [Enable or Disable Log Rotation](#enable-or-disable-log-rotation)
- [Enable or Disable Verbose Mode](#enable-or-disable-verbose-mode)
- [Display Configuration](#display-configuration)
- [Configuration](#configuration)
- [License](#license)
## Installation
Install RsLogMod using `pip`:
```bash
pip install rslogmod
```
Then import the module:
```python
from RsLogMod import rlog, Configure
```
## Getting Started
Here’s a simple example:
```python
from RsLogMod import rlog, Configure
# Set log folder path (only needed once, saved in config)
Configure.set_log_folder_path('path/to/log/folder')
# Log a message
rlog(log_name='my_log', log_level=1, log_entry='This is a log entry.')
```
### Explanation
- **`log_name`**: Name of the log file (e.g., `my_log`).
- **`log_level`**: Log level (`1` for INFO, `2` for ERROR, etc.).
- **`log_entry`**: The message to log.
- **`verbose`**: Optionally set `verbose=True` to print the message to the terminal as well.
## Default Behavior
1. **Log Rotation**: Enabled by default (log files rotate when they reach the set max size).
2. **Log to File and Terminal**: Logs are written to the file, and verbose mode controls whether they are printed to the terminal.
3. **Config Persistence**: Once paths are set, they are stored in a config file for future sessions.
## Log Levels & Prefixes
RsLogMod supports the following log levels, each with its own prefix:
- **0**: `[DEBUG]` - Detailed debug information.
- **1**: `[INFO]` - General program execution info.
- **2**: `[ERROR]` - Errors encountered during execution.
- **3**: `[CRITICAL]` - Critical issues that need attention.
- **4**: `[SEC-ALERT]` - Security-related alerts.
- **5**: `[SEC-BREACH]` - Security breaches or serious issues.
## Customization
### Set Log Folder Path
```python
Configure.set_log_folder_path('/path/to/logs')
```
### Set Archive Folder Path
```python
Configure.set_archive_path('/path/to/archive')
```
### Set Maximum Log Size
```python
Configure.set_log_file_max_size(50) # Max size is set in MB
```
### Enable or Disable Log Rotation
```python
Configure.enable_log_rotation(True) # Enable or disable log rotation
```
### Enable or Disable Verbose Mode
Verbose mode controls whether logs are printed to the terminal. It can be controlled globally via the config or for each individual `rlog()` call.
#### Global Verbose Mode
Enable verbose globally, applying to all future log entries unless overridden:
```python
Configure.enable_verbose(True) # Enable terminal printing for all logs
```
#### Per-Entry Verbose Mode
Control verbosity per log entry by using the `verbose` parameter in `rlog()`:
```python
rlog(log_name='my_log', log_level=1, log_entry='This will print to terminal', verbose=True)
```
### Verbose Mode Behavior
- If `verbose` is passed in `rlog()`, it overrides the global config.
- If not passed (`None`), it falls back to the config file setting.
- If both are unset (`None`), logs will only be written to the file.
#### Example Configuration:
```json
{
"log_rotation": true,
"verbose": null,
"max_size_in_mega_bytes": 50,
"log_folder": "path/to/logs",
"archive_folder": "path/to/archive"
}
```
- **`"verbose": true`**: Logs print to terminal and file.
- **`"verbose": false`**: Logs are only written to the file.
- **`"verbose": null`**: Behavior is controlled by the individual `rlog()` calls.
### Display Configuration
```python
Configure.display() # Display the current configuration in JSON format
```
## Configuration
RsLogMod stores its settings in a `configs.json` file:
```json
{
"log_rotation": true,
"verbose": null,
"max_size_in_mega_bytes": 50,
"log_folder": "/path/to/logs",
"archive_folder": "/path/to/logs/archived"
}
```
- **`log_rotation`**: Enables or disables log rotation.
- **`verbose`**: Controls whether logs are printed to the terminal.
- **`log_folder`**: Directory where logs are saved.
- **`archive_folder`**: Directory where archived logs are stored.
## License
This project is licensed under the [MIT License](https://github.com/D-3-X/Rodent-REPO/blob/main/licenses/MIT_License.txt). See the LICENSE file for details.
Raw data
{
"_id": null,
"home_page": "https://github.com/D-3-X/RsLogMod/",
"name": "RsLogMod",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": "logging, log rotation, python logging, programmable customization",
"author": "D-3-X",
"author_email": "felix.dxlan@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/a1/5e/b26b578473c0549bd43d3060e5b62c8abc117ea351c1b4735b4636f98ad0/rslogmod-1.0.2.tar.gz",
"platform": null,
"description": "# RsLogMod\n\n\n**RsLogMod** is a flexible and powerful Python logging module designed to manage log files with features such as log rotation, customizable paths, and various log levels. It is easy to use yet offers extensive customization options.\n\n## Table of Contents\n\n- [Installation](#installation)\n- [Getting Started](#getting-started)\n- [Default Behavior](#default-behavior)\n- [Log Levels & Prefixes](#log-levels--prefixes)\n- [Customization](#customization)\n - [Set Log Folder Path](#set-log-folder-path)\n - [Set Archive Folder Path](#set-archive-folder-path)\n - [Set Maximum Log Size](#set-maximum-log-size)\n - [Enable or Disable Log Rotation](#enable-or-disable-log-rotation)\n - [Enable or Disable Verbose Mode](#enable-or-disable-verbose-mode)\n - [Display Configuration](#display-configuration)\n- [Configuration](#configuration)\n- [License](#license)\n\n## Installation\n\nInstall RsLogMod using `pip`:\n\n```bash\npip install rslogmod\n```\n\nThen import the module:\n\n```python\nfrom RsLogMod import rlog, Configure\n```\n\n## Getting Started\n\nHere\u2019s a simple example:\n\n```python\nfrom RsLogMod import rlog, Configure\n\n# Set log folder path (only needed once, saved in config)\nConfigure.set_log_folder_path('path/to/log/folder')\n\n# Log a message\nrlog(log_name='my_log', log_level=1, log_entry='This is a log entry.')\n```\n\n### Explanation\n- **`log_name`**: Name of the log file (e.g., `my_log`).\n- **`log_level`**: Log level (`1` for INFO, `2` for ERROR, etc.).\n- **`log_entry`**: The message to log.\n- **`verbose`**: Optionally set `verbose=True` to print the message to the terminal as well.\n\n## Default Behavior\n\n1. **Log Rotation**: Enabled by default (log files rotate when they reach the set max size).\n2. **Log to File and Terminal**: Logs are written to the file, and verbose mode controls whether they are printed to the terminal.\n3. **Config Persistence**: Once paths are set, they are stored in a config file for future sessions.\n\n## Log Levels & Prefixes\n\nRsLogMod supports the following log levels, each with its own prefix:\n\n- **0**: `[DEBUG]` - Detailed debug information.\n- **1**: `[INFO]` - General program execution info.\n- **2**: `[ERROR]` - Errors encountered during execution.\n- **3**: `[CRITICAL]` - Critical issues that need attention.\n- **4**: `[SEC-ALERT]` - Security-related alerts.\n- **5**: `[SEC-BREACH]` - Security breaches or serious issues.\n\n## Customization\n\n### Set Log Folder Path\n\n```python\nConfigure.set_log_folder_path('/path/to/logs')\n```\n\n### Set Archive Folder Path\n\n```python\nConfigure.set_archive_path('/path/to/archive')\n```\n\n### Set Maximum Log Size\n\n```python\nConfigure.set_log_file_max_size(50) # Max size is set in MB\n```\n\n### Enable or Disable Log Rotation\n\n```python\nConfigure.enable_log_rotation(True) # Enable or disable log rotation\n```\n\n### Enable or Disable Verbose Mode\n\nVerbose mode controls whether logs are printed to the terminal. It can be controlled globally via the config or for each individual `rlog()` call.\n\n#### Global Verbose Mode\n\nEnable verbose globally, applying to all future log entries unless overridden:\n\n```python\nConfigure.enable_verbose(True) # Enable terminal printing for all logs\n```\n\n#### Per-Entry Verbose Mode\n\nControl verbosity per log entry by using the `verbose` parameter in `rlog()`:\n\n```python\nrlog(log_name='my_log', log_level=1, log_entry='This will print to terminal', verbose=True)\n```\n\n### Verbose Mode Behavior\n\n- If `verbose` is passed in `rlog()`, it overrides the global config.\n- If not passed (`None`), it falls back to the config file setting.\n- If both are unset (`None`), logs will only be written to the file.\n\n#### Example Configuration:\n\n```json\n{\n \"log_rotation\": true,\n \"verbose\": null,\n \"max_size_in_mega_bytes\": 50,\n \"log_folder\": \"path/to/logs\",\n \"archive_folder\": \"path/to/archive\"\n}\n```\n\n- **`\"verbose\": true`**: Logs print to terminal and file.\n- **`\"verbose\": false`**: Logs are only written to the file.\n- **`\"verbose\": null`**: Behavior is controlled by the individual `rlog()` calls.\n\n### Display Configuration\n\n```python\nConfigure.display() # Display the current configuration in JSON format\n```\n\n## Configuration\n\nRsLogMod stores its settings in a `configs.json` file:\n\n```json\n{\n \"log_rotation\": true,\n \"verbose\": null,\n \"max_size_in_mega_bytes\": 50,\n \"log_folder\": \"/path/to/logs\",\n \"archive_folder\": \"/path/to/logs/archived\"\n}\n```\n\n- **`log_rotation`**: Enables or disables log rotation.\n- **`verbose`**: Controls whether logs are printed to the terminal.\n- **`log_folder`**: Directory where logs are saved.\n- **`archive_folder`**: Directory where archived logs are stored.\n\n## License\n\nThis project is licensed under the [MIT License](https://github.com/D-3-X/Rodent-REPO/blob/main/licenses/MIT_License.txt). See the LICENSE file for details.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A versatile logging module for Python projects",
"version": "1.0.2",
"project_urls": {
"Bug Tracker": "https://github.com/D-3-X/RsLogMod/issues",
"Documentation": "https://github.com/D-3-X/RsLogMod#readme",
"Homepage": "https://github.com/D-3-X/RsLogMod/",
"Source Code": "https://github.com/D-3-X/RsLogMod"
},
"split_keywords": [
"logging",
" log rotation",
" python logging",
" programmable customization"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "86d8805b9d1305f205c9a3518d6bf103b9c98f8877bad95c78ff6da369cf3721",
"md5": "4408a9bba53d0e7c94aaf3ced45eab6b",
"sha256": "1c4916a42d15b914d5fb0492356259f2d05ed46ccfa4a1e3f775abafad719cd1"
},
"downloads": -1,
"filename": "RsLogMod-1.0.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "4408a9bba53d0e7c94aaf3ced45eab6b",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 7399,
"upload_time": "2024-10-13T05:19:48",
"upload_time_iso_8601": "2024-10-13T05:19:48.611963Z",
"url": "https://files.pythonhosted.org/packages/86/d8/805b9d1305f205c9a3518d6bf103b9c98f8877bad95c78ff6da369cf3721/RsLogMod-1.0.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "a15eb26b578473c0549bd43d3060e5b62c8abc117ea351c1b4735b4636f98ad0",
"md5": "096cbe4d7f2e07802d9d6e4f2d1064b3",
"sha256": "a97f1148bebb2639a499ec9953984d3d0fedc8d8db3cad06ab0865e77e2c3e64"
},
"downloads": -1,
"filename": "rslogmod-1.0.2.tar.gz",
"has_sig": false,
"md5_digest": "096cbe4d7f2e07802d9d6e4f2d1064b3",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 7787,
"upload_time": "2024-10-13T05:19:49",
"upload_time_iso_8601": "2024-10-13T05:19:49.964549Z",
"url": "https://files.pythonhosted.org/packages/a1/5e/b26b578473c0549bd43d3060e5b62c8abc117ea351c1b4735b4636f98ad0/rslogmod-1.0.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-13 05:19:49",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "D-3-X",
"github_project": "RsLogMod",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "rslogmod"
}