Name | fxlog JSON |
Version |
0.1.1
JSON |
| download |
home_page | https://github.com/healkeiser/fxlog |
Summary | A custom logging module for Python that supports colorized output and log file rotation. Includes features such as configurable log levels, custom formatters, and automatic deletion of old log files. |
upload_time | 2024-12-03 13:54:36 |
maintainer | None |
docs_url | None |
author | Valentin Beaumont |
requires_python | None |
license | MIT |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
colorama
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
<div align="center">
![Logo](https://raw.githubusercontent.com/healkeiser/fxlog/main/fxlog/images/icons/fxlog_logo_background_dark.svg#gh-light-mode-only)
![Logo](https://raw.githubusercontent.com/healkeiser/fxlog/main/fxlog/images/icons/fxlog_logo_background_light.svg#gh-dark-mode-only)
<h3 align="center">fxlog</h3>
<p align="center">
A custom logging module for Python that supports colorized output and log file rotation.
<br/><br/>
<!-- <a href="https://healkeiser.github.io/fxlog"><strong>Documentation</strong></a> -->
</p>
##
<p align="center">
<!-- Maintenance status -->
<img src="https://img.shields.io/badge/maintenance-actively--developed-brightgreen.svg?&label=Maintenance">
<!-- <img src="https://img.shields.io/badge/maintenance-deprecated-red.svg?&label=Maintenance"> -->
<!-- License -->
<img src="https://img.shields.io/badge/License-MIT-brightgreen.svg?&logo=open-source-initiative&logoColor=white" alt="License: MIT"/>
<!-- PyPI -->
<a href="https://pypi.org/project/fxlog">
<img src="https://img.shields.io/pypi/v/fxlog?&logo=pypi&logoColor=white&label=PyPI" alt="PyPI version"/></a>
<!-- PyPI downloads -->
<a href="https://pepy.tech/project/fxlog">
<img src="https://static.pepy.tech/badge/fxlog" alt="PyPI Downloads"></a>
<!-- Last Commit -->
<img src="https://img.shields.io/github/last-commit/healkeiser/fxlog?logo=github&label=Last%20Commit" alt="Last Commit"/>
<!-- Commit Activity -->
<a href="https://github.com/healkeiser/fxlog/pulse" alt="Activity">
<img src="https://img.shields.io/github/commit-activity/m/healkeiser/fxlog?&logo=github&label=Commit%20Activity"/></a>
<!-- GitHub stars -->
<img src="https://img.shields.io/github/stars/healkeiser/fxlog" alt="GitHub Stars"/>
</p>
</div>
<!-- TABLE OF CONTENTS -->
## Table of Contents
- [About](#about)
- [Installation](#installation)
- [How-to Use](#how-to-use)
- [Save Log Files](#save-log-files)
- [Do Not Save Log Files](#do-not-save-log-files)
- [Set Log Level](#set-log-level)
- [Set Formatter](#set-formatter)
- [Contact](#contact)
<!-- ABOUT -->
## About
A custom logging module for Python that supports colorized output and log file rotation. Includes features such as configurable log levels, custom formatters, and automatic deletion of old log files.
<!-- INSTALLATION -->
## Installation
The package is available on [PyPI](https://pypi.org/project/fxlog) and can be installed via `pip`:
```shell
python -m pip install fxlog
```
<!-- HOW-TO USE -->
## How-to Use
You can use the `fxlog` module in your Python scripts as follows:
### Save Log Files
If you want to save the log files <sup>[1](#footnote1)</sup>, import the `fxlog` module, and set the log directory where log files will be stored:
```python
from fxlog import fxlogger
fxlogger.set_log_directory('path/to/log/directory')
```
E.g.,
```python
import os
from pathlib import Path
from fxlog import fxlogger
_PACKAGE_NAME = "package_name"
DATA_DIR = (
Path(os.getenv("APPDATA")) / _PACKAGE_NAME
if os.name == "nt"
else Path.home() / f".{_PACKAGE_NAME}"
)
LOG_DIR = DATA_DIR / "logs"
LOG_DIR.mkdir(parents=True, exist_ok=True)
fxlogger.set_log_directory(LOG_DIR)
```
> [!NOTE]
> This only needs to be done once in your package.
Then, you can use the `fxlog` module to create a logger object and log messages to the console and a log file:
```python
from fxlog import fxlogger
logger = fxlogger.configure_logger('my_logger')
logger.debug('This is a debug message')
```
To delete old log files, you can use the `fxlog` module as follows:
```python
from fxlog import fxlogger
fxlogger.delete_old_logs(7) # Delete log files older than 7 days
```
You can also clear all log files in the log directory:
```python
from fxlog import fxlogger
fxlogger.clear_logs()
```
> [!NOTE]
> <sup id="footnote1">1</sup> The log files are constructed with the following naming convention: `<logger_name>_<year>-<month>-<day>.log`.
### Do Not Save Log Files
If you don't want to save the log files, you can use the `fxlog` module as follows:
```python
from fxlog import fxlogger
logger = fxlogger.configure_logger('my_logger', save_to_file=False)
logger.debug('This is a debug message')
```
### Set Log Level
You can set the log level of **all** loggers by using the `set_loggers_level` function:
```python
from fxlog import fxlogger
fxlogger.set_loggers_level(fxlogger.DEBUG) # You can also use `logging.DEBUG`
```
### Set Formatter
By default, the output looks like this:
<p align="center">
<img width="800" src="docs/images/basic.png">
</p>
You can enable a colored output by setting the `enable_color` parameter to `True`. The messages will be colorized according to their log levels:
```python
from fxlog import fxlogger
logger = fxlogger.configure_logger('my_logger', enable_color=True)
logger.debug('This is a debug message')
```
<p align="center">
<img width="800" src="docs/images/color.png">
</p>
> [!NOTE]
> Colors are not saved in log files.
> [!WARNING]
> If `enable_color` is set to `True` but the terminal does not support colorized output, the messages will be displayed in their original form.
You can also enable a separator between log messages by setting the `enable_separator` parameter to `True`:
```python
from fxlog import fxlogger
logger = fxlogger.configure_logger('my_logger', enable_separator=True)
logger.debug('This is a debug message')
```
<p align="center">
<img width="800" src="docs/images/color_separator.png">
</p>
<!-- CONTACT -->
## Contact
Project Link: [fxlog](https://github.com/healkeiser/fxlog)
<p align='center'>
<!-- GitHub profile -->
<a href="https://github.com/healkeiser">
<img src="https://img.shields.io/badge/healkeiser-181717?logo=github&style=social" alt="GitHub"/></a>
<!-- LinkedIn -->
<a href="https://www.linkedin.com/in/valentin-beaumont">
<img src="https://img.shields.io/badge/Valentin%20Beaumont-0A66C2?logo=linkedin&style=social" alt="LinkedIn"/></a>
<!-- Behance -->
<a href="https://www.behance.net/el1ven">
<img src="https://img.shields.io/badge/el1ven-1769FF?logo=behance&style=social" alt="Behance"/></a>
<!-- X -->
<a href="https://twitter.com/valentinbeaumon">
<img src="https://img.shields.io/badge/@valentinbeaumon-1DA1F2?logo=x&style=social" alt="Twitter"/></a>
<!-- Instagram -->
<a href="https://www.instagram.com/val.beaumontart">
<img src="https://img.shields.io/badge/@val.beaumontart-E4405F?logo=instagram&style=social" alt="Instagram"/></a>
<!-- Gumroad -->
<a href="https://healkeiser.gumroad.com/subscribe">
<img src="https://img.shields.io/badge/healkeiser-36a9ae?logo=gumroad&style=social" alt="Gumroad"/></a>
<!-- Gmail -->
<a href="mailto:valentin.onze@gmail.com">
<img src="https://img.shields.io/badge/valentin.onze@gmail.com-D14836?logo=gmail&style=social" alt="Email"/></a>
<!-- Buy me a coffee -->
<a href="https://www.buymeacoffee.com/healkeiser">
<img src="https://img.shields.io/badge/Buy Me A Coffee-FFDD00?&logo=buy-me-a-coffee&logoColor=black" alt="Buy Me A Coffee"/></a>
</p>
Raw data
{
"_id": null,
"home_page": "https://github.com/healkeiser/fxlog",
"name": "fxlog",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": null,
"author": "Valentin Beaumont",
"author_email": "valentin.onze@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/e0/a3/08d85298eb02ffd15cfec6dc7381f1514e7b2652b226276e54dd919dd78a/fxlog-0.1.1.tar.gz",
"platform": null,
"description": "<div align=\"center\">\n\n ![Logo](https://raw.githubusercontent.com/healkeiser/fxlog/main/fxlog/images/icons/fxlog_logo_background_dark.svg#gh-light-mode-only)\n ![Logo](https://raw.githubusercontent.com/healkeiser/fxlog/main/fxlog/images/icons/fxlog_logo_background_light.svg#gh-dark-mode-only)\n\n <h3 align=\"center\">fxlog</h3>\n\n <p align=\"center\">\n A custom logging module for Python that supports colorized output and log file rotation.\n <br/><br/>\n <!-- <a href=\"https://healkeiser.github.io/fxlog\"><strong>Documentation</strong></a> -->\n </p>\n\n ##\n\n <p align=\"center\">\n <!-- Maintenance status -->\n <img src=\"https://img.shields.io/badge/maintenance-actively--developed-brightgreen.svg?&label=Maintenance\"> \n <!-- <img src=\"https://img.shields.io/badge/maintenance-deprecated-red.svg?&label=Maintenance\"> -->\n <!-- License -->\n <img src=\"https://img.shields.io/badge/License-MIT-brightgreen.svg?&logo=open-source-initiative&logoColor=white\" alt=\"License: MIT\"/> \n <!-- PyPI -->\n <a href=\"https://pypi.org/project/fxlog\">\n <img src=\"https://img.shields.io/pypi/v/fxlog?&logo=pypi&logoColor=white&label=PyPI\" alt=\"PyPI version\"/></a> \n <!-- PyPI downloads -->\n <a href=\"https://pepy.tech/project/fxlog\">\n <img src=\"https://static.pepy.tech/badge/fxlog\" alt=\"PyPI Downloads\"></a> \n <!-- Last Commit -->\n <img src=\"https://img.shields.io/github/last-commit/healkeiser/fxlog?logo=github&label=Last%20Commit\" alt=\"Last Commit\"/> \n <!-- Commit Activity -->\n <a href=\"https://github.com/healkeiser/fxlog/pulse\" alt=\"Activity\">\n <img src=\"https://img.shields.io/github/commit-activity/m/healkeiser/fxlog?&logo=github&label=Commit%20Activity\"/></a> \n <!-- GitHub stars -->\n <img src=\"https://img.shields.io/github/stars/healkeiser/fxlog\" alt=\"GitHub Stars\"/> \n </p>\n\n</div>\n\n\n\n<!-- TABLE OF CONTENTS -->\n## Table of Contents\n\n- [About](#about)\n- [Installation](#installation)\n- [How-to Use](#how-to-use)\n - [Save Log Files](#save-log-files)\n - [Do Not Save Log Files](#do-not-save-log-files)\n - [Set Log Level](#set-log-level)\n - [Set Formatter](#set-formatter)\n- [Contact](#contact)\n\n\n\n<!-- ABOUT -->\n## About\n\nA custom logging module for Python that supports colorized output and log file rotation. Includes features such as configurable log levels, custom formatters, and automatic deletion of old log files.\n\n\n\n<!-- INSTALLATION -->\n## Installation\n\nThe package is available on [PyPI](https://pypi.org/project/fxlog) and can be installed via `pip`:\n\n```shell\npython -m pip install fxlog\n```\n\n\n\n<!-- HOW-TO USE -->\n## How-to Use\n\nYou can use the `fxlog` module in your Python scripts as follows:\n\n### Save Log Files\n\nIf you want to save the log files <sup>[1](#footnote1)</sup>, import the `fxlog` module, and set the log directory where log files will be stored:\n\n```python\nfrom fxlog import fxlogger\n\nfxlogger.set_log_directory('path/to/log/directory')\n```\n\nE.g.,\n\n```python\nimport os\nfrom pathlib import Path\nfrom fxlog import fxlogger\n\n\n_PACKAGE_NAME = \"package_name\"\nDATA_DIR = (\n Path(os.getenv(\"APPDATA\")) / _PACKAGE_NAME\n if os.name == \"nt\"\n else Path.home() / f\".{_PACKAGE_NAME}\"\n)\nLOG_DIR = DATA_DIR / \"logs\"\nLOG_DIR.mkdir(parents=True, exist_ok=True)\n\nfxlogger.set_log_directory(LOG_DIR)\n```\n\n> [!NOTE]\n> This only needs to be done once in your package.\n\nThen, you can use the `fxlog` module to create a logger object and log messages to the console and a log file:\n\n```python\nfrom fxlog import fxlogger\n\nlogger = fxlogger.configure_logger('my_logger')\nlogger.debug('This is a debug message')\n```\n\nTo delete old log files, you can use the `fxlog` module as follows:\n\n```python\nfrom fxlog import fxlogger\n\nfxlogger.delete_old_logs(7) # Delete log files older than 7 days\n```\n\nYou can also clear all log files in the log directory:\n\n```python\nfrom fxlog import fxlogger\n\nfxlogger.clear_logs()\n```\n\n> [!NOTE]\n> <sup id=\"footnote1\">1</sup> The log files are constructed with the following naming convention: `<logger_name>_<year>-<month>-<day>.log`.\n\n### Do Not Save Log Files\n\nIf you don't want to save the log files, you can use the `fxlog` module as follows:\n\n```python\nfrom fxlog import fxlogger\n\nlogger = fxlogger.configure_logger('my_logger', save_to_file=False)\nlogger.debug('This is a debug message')\n```\n\n### Set Log Level\n\nYou can set the log level of **all** loggers by using the `set_loggers_level` function:\n\n```python\nfrom fxlog import fxlogger\n\nfxlogger.set_loggers_level(fxlogger.DEBUG) # You can also use `logging.DEBUG`\n```\n\n### Set Formatter\n\nBy default, the output looks like this:\n\n<p align=\"center\">\n <img width=\"800\" src=\"docs/images/basic.png\">\n</p>\n\nYou can enable a colored output by setting the `enable_color` parameter to `True`. The messages will be colorized according to their log levels:\n\n```python\nfrom fxlog import fxlogger\n\nlogger = fxlogger.configure_logger('my_logger', enable_color=True)\nlogger.debug('This is a debug message')\n```\n\n<p align=\"center\">\n <img width=\"800\" src=\"docs/images/color.png\">\n</p>\n\n> [!NOTE]\n> Colors are not saved in log files.\n\n> [!WARNING]\n> If `enable_color` is set to `True` but the terminal does not support colorized output, the messages will be displayed in their original form.\n\nYou can also enable a separator between log messages by setting the `enable_separator` parameter to `True`:\n\n```python\nfrom fxlog import fxlogger\n\nlogger = fxlogger.configure_logger('my_logger', enable_separator=True)\nlogger.debug('This is a debug message')\n```\n\n<p align=\"center\">\n <img width=\"800\" src=\"docs/images/color_separator.png\">\n</p>\n\n\n\n<!-- CONTACT -->\n## Contact\n\nProject Link: [fxlog](https://github.com/healkeiser/fxlog)\n\n<p align='center'>\n <!-- GitHub profile -->\n <a href=\"https://github.com/healkeiser\">\n <img src=\"https://img.shields.io/badge/healkeiser-181717?logo=github&style=social\" alt=\"GitHub\"/></a> \n <!-- LinkedIn -->\n <a href=\"https://www.linkedin.com/in/valentin-beaumont\">\n <img src=\"https://img.shields.io/badge/Valentin%20Beaumont-0A66C2?logo=linkedin&style=social\" alt=\"LinkedIn\"/></a> \n <!-- Behance -->\n <a href=\"https://www.behance.net/el1ven\">\n <img src=\"https://img.shields.io/badge/el1ven-1769FF?logo=behance&style=social\" alt=\"Behance\"/></a> \n <!-- X -->\n <a href=\"https://twitter.com/valentinbeaumon\">\n <img src=\"https://img.shields.io/badge/@valentinbeaumon-1DA1F2?logo=x&style=social\" alt=\"Twitter\"/></a> \n <!-- Instagram -->\n <a href=\"https://www.instagram.com/val.beaumontart\">\n <img src=\"https://img.shields.io/badge/@val.beaumontart-E4405F?logo=instagram&style=social\" alt=\"Instagram\"/></a> \n <!-- Gumroad -->\n <a href=\"https://healkeiser.gumroad.com/subscribe\">\n <img src=\"https://img.shields.io/badge/healkeiser-36a9ae?logo=gumroad&style=social\" alt=\"Gumroad\"/></a> \n <!-- Gmail -->\n <a href=\"mailto:valentin.onze@gmail.com\">\n <img src=\"https://img.shields.io/badge/valentin.onze@gmail.com-D14836?logo=gmail&style=social\" alt=\"Email\"/></a> \n <!-- Buy me a coffee -->\n <a href=\"https://www.buymeacoffee.com/healkeiser\">\n <img src=\"https://img.shields.io/badge/Buy Me A Coffee-FFDD00?&logo=buy-me-a-coffee&logoColor=black\" alt=\"Buy Me A Coffee\"/></a> \n</p>\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A custom logging module for Python that supports colorized output and log file rotation. Includes features such as configurable log levels, custom formatters, and automatic deletion of old log files.",
"version": "0.1.1",
"project_urls": {
"Changelog": "https://github.com/healkeiser/fxlog/blob/main/CHANGELOG.md",
"Documentation": "https://healkeiser.github.io/fxlog",
"Funding": "https://github.com/sponsors/healkeiser",
"GitHub": "https://github.com/healkeiser/fxlog",
"Homepage": "https://github.com/healkeiser/fxlog",
"Source": "https://github.com/healkeiser/fxlog"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "eca5e91e420bfbf381c3b2853cb3a6cc993d0d0ca2adc29dda68fe2985a7ac43",
"md5": "eda405a1170715e9cb4385738297599d",
"sha256": "fc580c4dba15b2c5bcdd2921b1f1910e17fd6f5fe0b1c20d81f82c060237a84f"
},
"downloads": -1,
"filename": "fxlog-0.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "eda405a1170715e9cb4385738297599d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 11597,
"upload_time": "2024-12-03T13:54:34",
"upload_time_iso_8601": "2024-12-03T13:54:34.932762Z",
"url": "https://files.pythonhosted.org/packages/ec/a5/e91e420bfbf381c3b2853cb3a6cc993d0d0ca2adc29dda68fe2985a7ac43/fxlog-0.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e0a308d85298eb02ffd15cfec6dc7381f1514e7b2652b226276e54dd919dd78a",
"md5": "1edb10b83ce378c7d682f6990c6567f2",
"sha256": "9608ae6120398deba87a52068b05d140ec7159dca9dee9e6a9b39b5c538f0c4f"
},
"downloads": -1,
"filename": "fxlog-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "1edb10b83ce378c7d682f6990c6567f2",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 1639619,
"upload_time": "2024-12-03T13:54:36",
"upload_time_iso_8601": "2024-12-03T13:54:36.574620Z",
"url": "https://files.pythonhosted.org/packages/e0/a3/08d85298eb02ffd15cfec6dc7381f1514e7b2652b226276e54dd919dd78a/fxlog-0.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-03 13:54:36",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "healkeiser",
"github_project": "fxlog",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "colorama",
"specs": []
}
],
"lcname": "fxlog"
}