Skip to main content

Made Tech R&D Logger

Project description

Rnd Logger

A python logger implementation for the Made Tech R&D department

This implementation adds flexibility for in and out of office hours alerts and inherits from the root logger provided by the python logging module. There are two log handlers available, the standard root logger and a json logger

Testing

  • run make test

Creating a release

  • Commit your changes to main and then create a release on Github.
  • This will trigger a Github action that will increment the version with the tag you have chosen and publish that version to PyPi
  • Please use semantic versioning and version relative to the change you have made

Usage

  1. Use the rnd_logger:
  2. Root Logger:
from rnd_logger import rnd_logger
logger = rnd_logger.get_logger()
   
def your_test_code():
    logger.debug("Debug message")
    logger.info("Info message")
    logger.warning("Warning message")
    logger.error_office_hours_alert("Office hours alert message")
    logger.error_out_of_hours_alert("Out of office hours alert message")
  1. Json Logger:
from rnd_logger import rnd_logger
logger = rnd_logger.get_logger("json")
   
def your_test_code():
    logger.debug("Debug message", extra={"json_key": "json_value"})
    logger.info("Info message", extra={"json_key": "json_value"})
    logger.warning("Warning message", extra={"json_key": "json_value"})
    logger.error_office_hours_alert("Office hours alert message", extra={"json_key": "json_value"})
    logger.error_out_of_hours_alert("Out of office hours alert message", extra={"json_key": "json_value"})
  1. Testing the rnd_logger: 3. There is a caplog fixture provided by pytest
import logging
def test_use_case_logs_info(caplog, use_case_under_test):
    with caplog.at_level(logging.INFO):
        your_test_code()
        records = iter(caplog.records)
        record = next(records)
        assert record.message == "your test log"

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

rnd_logger-1.4.4.tar.gz (2.5 kB view details)

Uploaded Source

Built Distribution

rnd_logger-1.4.4-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

Details for the file rnd_logger-1.4.4.tar.gz.

File metadata

  • Download URL: rnd_logger-1.4.4.tar.gz
  • Upload date:
  • Size: 2.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for rnd_logger-1.4.4.tar.gz
Algorithm Hash digest
SHA256 0c88d7bc7e397f00d41ac84c0370b5aeaecc016ebe7c8f963f62dbc967f840b5
MD5 c67cbbe3322e0a3633f976db9fd53df6
BLAKE2b-256 9178627c17d44265e6d4577546ab330788c17ea39e920904bbd08855d433d860

See more details on using hashes here.

File details

Details for the file rnd_logger-1.4.4-py3-none-any.whl.

File metadata

  • Download URL: rnd_logger-1.4.4-py3-none-any.whl
  • Upload date:
  • Size: 3.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for rnd_logger-1.4.4-py3-none-any.whl
Algorithm Hash digest
SHA256 1445cc8c8fc92b3faf2f36808308e8370aba169ebdd8744c1d4583205048e8b1
MD5 a3fdd49190680a2104f23f516534525a
BLAKE2b-256 0ffff9fa145925e3baf32e9b5caffc080c5baf81a32d8523717c8c5f9e7253dd

See more details on using hashes here.

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