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.7.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: ddclogs-2.0.7.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.7.tar.gz
Algorithm Hash digest
SHA256 4d2f8d4089b4465cebe7ae5c09c90a7e987b36979994d4221de8816ac9590663
MD5 641cb1cd89b363419567708f95d1971e
BLAKE2b-256 3a922f9c51f826d5e8cd6311955ab0685552346d28149a54f82917e8afad5b1e

See more details on using hashes here.

Provenance

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

Publisher: workflow.yml on ddc/ddcLogs

Attestations:

File details

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

File metadata

  • Download URL: ddclogs-2.0.7-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.7-py3-none-any.whl
Algorithm Hash digest
SHA256 2e1c5ba0e61a8f38a06e7a79f6dced4d3a37accc94466bed06f5d44ceab00d6f
MD5 2f9a986c319d118bb3f3526fb69c8469
BLAKE2b-256 8f972defaa2b4ce3197e5e8a66c48bb34992c6b5eddb54cc6b3aad98dace84e9

See more details on using hashes here.

Provenance

The following attestation bundles were made for ddclogs-2.0.7-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