# Log Functions
[![License](https://img.shields.io/github/license/ddc/ddcLogs.svg?style=plastic)](https://github.com/ddc/ddcLogs/blob/master/LICENSE)
[![Python](https://img.shields.io/badge/Python-3.10+-blue.svg?style=plastic)](https://www.python.org)
[![PyPi](https://img.shields.io/pypi/v/ddcLogs.svg?style=plastic)](https://pypi.python.org/pypi/ddcLogs)
[![Build Status](https://img.shields.io/endpoint.svg?url=https%3A//actions-badge.atrox.dev/ddc/ddcLogs/badge?ref=main&style=plastic&label=build&logo=none)](https://actions-badge.atrox.dev/ddc/ddcLogs/goto?ref=main)
# Install
```shell
pip install ddcLogs
```
# BasicLog
+ Setup Logging
+ This is just a basic log, it does not use any file
```python
from ddcLogs import BasicLog
logger = BasicLog(
level="info",
name = "app",
utc = True,
show_location = False, # This will show the filename and the line number where the message originated
).init()
logger.warning("This is a warning example")
```
# SizeRotatingLog
+ Setup Logging
+ Logs will rotate based on the file size
+ Logs will be deleted based on the `days_to_keep` variable, defaults to 30
```python
from ddcLogs import SizeRotatingLog
logger = SizeRotatingLog(
level = "info",
directory = "logs",
filenames = ["app.log", "app1.log"],
days_to_keep = 7,
max_mbytes = 5,
name = "app",
utc = True,
stream_handler = True, # Add stream handler along with file handler
show_location = False # This will show the filename and the line number where the message originated
).init()
logger.warning("This is a warning example")
```
# TimedRotatingLog
+ Setup Logging
+ Logs will rotate based on `when` variable to a `.gz` file, defaults to `midnight`
+ Logs will be deleted based on the `days_to_keep` variable, defaults to 30
+ Current 'when' events supported:
+ midnight - roll over at midnight
+ W{0-6} - roll over on a certain day; 0 - Monday
```python
from ddcLogs import TimedRotatingLog
logger = TimedRotatingLog(
level = "info",
directory = "logs",
filenames = ["app.log", "app1.log"],
days_to_keep = 7,
when = "midnight",
name = "app",
utc = True,
stream_handler = True, # Add stream handler along with file handler
show_location = False # This will show the filename and the line number where the message originated
).init()
logger.warning("This is a warning example")
```
### Example of output
`[2024-10-08T19:08:56.918]:[WARNING]:[app]:This is a warning example`
# Source Code
### Build
```shell
poetry build -f wheel
```
### Publish to test pypi
```shell
poetry publish -r test-pypi
```
### Publish to pypi
```shell
poetry publish
```
### Run Tests and Get Coverage Report
```shell
poetry run coverage run --omit=./tests/* --source=./ddcLogs -m pytest -v && poetry run coverage report
```
# License
Released under the [MIT License](LICENSE)
Raw data
{
"_id": null,
"home_page": "https://github.com/ddc/ddcLogs",
"name": "ddcLogs",
"maintainer": "Daniel Costa",
"docs_url": null,
"requires_python": "<4.0,>=3.10",
"maintainer_email": null,
"keywords": "python3, log, log-utils, log_utils, logger, ddcLogs",
"author": "Daniel Costa",
"author_email": "danieldcsta@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/a7/92/8bf4c0ed16d8e9241f589a0519306f820e86ccd0361515a03e7db9ee3292/ddclogs-2.0.18.tar.gz",
"platform": null,
"description": "# Log Functions\n\n[![License](https://img.shields.io/github/license/ddc/ddcLogs.svg?style=plastic)](https://github.com/ddc/ddcLogs/blob/master/LICENSE)\n[![Python](https://img.shields.io/badge/Python-3.10+-blue.svg?style=plastic)](https://www.python.org)\n[![PyPi](https://img.shields.io/pypi/v/ddcLogs.svg?style=plastic)](https://pypi.python.org/pypi/ddcLogs)\n[![Build Status](https://img.shields.io/endpoint.svg?url=https%3A//actions-badge.atrox.dev/ddc/ddcLogs/badge?ref=main&style=plastic&label=build&logo=none)](https://actions-badge.atrox.dev/ddc/ddcLogs/goto?ref=main)\n\n\n# Install\n```shell\npip install ddcLogs\n```\n\n\n# BasicLog\n+ Setup Logging\n + This is just a basic log, it does not use any file\n```python\nfrom ddcLogs import BasicLog\nlogger = BasicLog(\n level=\"info\",\n name = \"app\",\n utc = True,\n show_location = False, # This will show the filename and the line number where the message originated\n).init()\nlogger.warning(\"This is a warning example\")\n```\n\n\n# SizeRotatingLog\n+ Setup Logging\n + Logs will rotate based on the file size\n + Logs will be deleted based on the `days_to_keep` variable, defaults to 30\n```python\nfrom ddcLogs import SizeRotatingLog\nlogger = SizeRotatingLog(\n level = \"info\",\n directory = \"logs\",\n filenames = [\"app.log\", \"app1.log\"],\n days_to_keep = 7,\n max_mbytes = 5,\n name = \"app\",\n utc = True,\n stream_handler = True, # Add stream handler along with file handler\n show_location = False # This will show the filename and the line number where the message originated\n).init()\nlogger.warning(\"This is a warning example\")\n```\n\n\n# TimedRotatingLog\n+ Setup Logging\n + Logs will rotate based on `when` variable to a `.gz` file, defaults to `midnight`\n + Logs will be deleted based on the `days_to_keep` variable, defaults to 30\n + Current 'when' events supported:\n + midnight - roll over at midnight\n + W{0-6} - roll over on a certain day; 0 - Monday\n```python\nfrom ddcLogs import TimedRotatingLog\nlogger = TimedRotatingLog(\n level = \"info\",\n directory = \"logs\",\n filenames = [\"app.log\", \"app1.log\"],\n days_to_keep = 7,\n when = \"midnight\",\n name = \"app\",\n utc = True,\n stream_handler = True, # Add stream handler along with file handler\n show_location = False # This will show the filename and the line number where the message originated\n).init()\nlogger.warning(\"This is a warning example\")\n```\n\n### Example of output\n`[2024-10-08T19:08:56.918]:[WARNING]:[app]:This is a warning example`\n\n\n\n# Source Code\n### Build\n```shell\npoetry build -f wheel\n```\n\n\n### Publish to test pypi\n```shell\npoetry publish -r test-pypi\n```\n\n\n### Publish to pypi\n```shell\npoetry publish\n```\n\n\n### Run Tests and Get Coverage Report\n```shell\npoetry run coverage run --omit=./tests/* --source=./ddcLogs -m pytest -v && poetry run coverage report\n```\n\n\n# License\nReleased under the [MIT License](LICENSE)\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Easy logs with rotations",
"version": "2.0.18",
"project_urls": {
"Homepage": "https://github.com/ddc/ddcLogs",
"Repository": "https://github.com/ddc/ddcLogs"
},
"split_keywords": [
"python3",
" log",
" log-utils",
" log_utils",
" logger",
" ddclogs"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "597cca66f20dc8c98ed954becc9c10cc01038cd3a42f778160813b7804d56d4d",
"md5": "842ba67f79b0257f0bce5746dcbc6db4",
"sha256": "d9a22c7a645b6a236dd7739db8b77d9d67ec5a22a1050188b17b6deccf796bbc"
},
"downloads": -1,
"filename": "ddclogs-2.0.18-py3-none-any.whl",
"has_sig": false,
"md5_digest": "842ba67f79b0257f0bce5746dcbc6db4",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.10",
"size": 9728,
"upload_time": "2024-11-28T18:03:58",
"upload_time_iso_8601": "2024-11-28T18:03:58.513595Z",
"url": "https://files.pythonhosted.org/packages/59/7c/ca66f20dc8c98ed954becc9c10cc01038cd3a42f778160813b7804d56d4d/ddclogs-2.0.18-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "a7928bf4c0ed16d8e9241f589a0519306f820e86ccd0361515a03e7db9ee3292",
"md5": "186d2412c7448d58ec7cbaf3fffebc2c",
"sha256": "5275de33e9e9ec0cc4d158f21d21637bdd1de0b3559a01025bd4dce629439903"
},
"downloads": -1,
"filename": "ddclogs-2.0.18.tar.gz",
"has_sig": false,
"md5_digest": "186d2412c7448d58ec7cbaf3fffebc2c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.10",
"size": 7819,
"upload_time": "2024-11-28T18:03:59",
"upload_time_iso_8601": "2024-11-28T18:03:59.731183Z",
"url": "https://files.pythonhosted.org/packages/a7/92/8bf4c0ed16d8e9241f589a0519306f820e86ccd0361515a03e7db9ee3292/ddclogs-2.0.18.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-28 18:03:59",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "ddc",
"github_project": "ddcLogs",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "ddclogs"
}