Skip to main content

Custom log with rotations

Project description

Log Functions

License Python PyPi Build Status

Install

pip install ddcLogs

BasicLog

  • Setup Logging
from ddcLogs import BasicLog
logger = BasicLog(level="info").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
from ddcLogs import SizeRotatingLog
logger = SizeRotatingLog(
    level = "info",
    directory = "logs",
    filenames = ["app.log", "app1.log"],
    days_to_keep = 7,
    max_mbytes = 5,
    name = "app_name",
    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
from ddcLogs import TimedRotatingLog
logger = TimedRotatingLog(
    level = "info",
    directory = "logs",
    filenames = ["app.log", "app1.log"],
    days_to_keep = 7,
    when = "midnight",
    utc = True,
    name = "app_name",
    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_name]:This is a warning example

Source Code

Build

poetry build -f wheel

Publish to test pypi

poetry publish -r test-pypi

Publish to pypi

poetry publish

Run Tests

poetry run coverage run -m pytest -v

Get Coverage Report

poetry run coverage report

License

Released 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

ddclogs-2.0.6.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

ddclogs-2.0.6-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file ddclogs-2.0.6.tar.gz.

File metadata

  • Download URL: ddclogs-2.0.6.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for ddclogs-2.0.6.tar.gz
Algorithm Hash digest
SHA256 c9acc8b596323fef0254441c70324710ea04e340c879c642a34a81fec9514adb
MD5 c7b5cc876200f68b88daacd230abd292
BLAKE2b-256 61269d7877284d081c8ce43a478a8654433cb67d90a572a2be4c3b2b49a32b20

See more details on using hashes here.

Provenance

The following attestation bundles were made for ddclogs-2.0.6.tar.gz:

Publisher: workflow.yml on ddc/ddcLogs

Attestations:

File details

Details for the file ddclogs-2.0.6-py3-none-any.whl.

File metadata

  • Download URL: ddclogs-2.0.6-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for ddclogs-2.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 307aeb346feb44d79d6b2998f3b0fdec18ccab511b75e25371e127eee0b54b41
MD5 790bc6e06f2aa7ef5f47c9e665ccc1ad
BLAKE2b-256 153a996ee718a40ab99fa461d3c9d6ace222d6b6c5af84fb9e8cd5e01c5a7e72

See more details on using hashes here.

Provenance

The following attestation bundles were made for ddclogs-2.0.6-py3-none-any.whl:

Publisher: workflow.yml on ddc/ddcLogs

Attestations:

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page