Skip to main content

Common logging functions for SRE python scripts.

Project description

SRE Logging

Common logging setup package for SRE python programs.

If you have a Python program that's gonna be anywhere near production, or is in any way 'mission critical', it should use this package so that it can plug into our DataDog log analysis very easily.

Installation

pip install srelogging

Usage

In your program, as soon as the application starts, you'll want to call srelogging.configure_logging():

import srelogging

# ...

srelogging.configure_logging()

Additionally, if you want to specify any custom logging config (in Python logging dictConfig format) then you can specify a file path in the arguments to configure_logging():

srelogging.configure_logging("logging_config.yml")
# contents of logging_config.yml
version: 1
formatters:
  default:
    class: srelogging.UTCFormatter
    format: "%(asctime)s.%(msecs)03dZ [%(levelname)s] <%(module)s.py:%(lineno)d> %(message)s"
    datefmt: "%Y-%m-%d %H:%M:%S"
handlers:
  console:
    class: logging.StreamHandler
    level: DEBUG
    formatter: default
    stream: ext://sys.stdout
root:
  level: WARNING
  handlers: [console]

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

srelogging-0.0.3.tar.gz (2.9 kB view hashes)

Uploaded Source

Built Distribution

srelogging-0.0.3-py3-none-any.whl (3.0 kB view hashes)

Uploaded Python 3

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