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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

Details for the file srelogging-0.0.3.tar.gz.

File metadata

  • Download URL: srelogging-0.0.3.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

File hashes

Hashes for srelogging-0.0.3.tar.gz
Algorithm Hash digest
SHA256 549fd364d993af7cada9287589df2be62ce76ba99139a50125a270c7f688e3e9
MD5 aa2bd995f9b4a6ff3be6a2321ef14c34
BLAKE2b-256 018f77aa421b1b19490c130dea10cc99aad839e25f17c2df3ecf3540d62c2c8e

See more details on using hashes here.

File details

Details for the file srelogging-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: srelogging-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 3.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

File hashes

Hashes for srelogging-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e8332159e7b41eff6d3e2573f94d5df160aa95cc60d979cec0a3c7ba207c0d41
MD5 13461b35625e50a2e18f03bd70bd1779
BLAKE2b-256 ac8f772750e53e9848f66c7c4d8ad52b30464d852ff4a140b2f846b677f1201b

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