Skip to main content

Tracer util allowing masking of arguments in the log

Project description

LogTracer

Log utility allowing detailed tracing of function execution while at the same time masking arguments by name

Description

LogTracer provides a decorator method, enabling detailed output of function execution to facilitate tracing, while at the same time allowing masking of arguments by argument name. The trace method will mask the value of arguments with a name matching any of the string arguments provided to the method.

Example implementation:

import logging
from logtracer import LogTracer

logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(name)s  - %(levelname)s - %(message)s')
log = logging.getLogger(__name__)
lt = LogTracer(log)

@lt.trace("password", "pw")
def login(user, pw, username=None, password=None):
    pass

login("Arnold", "MyS3cr3tP4ssw0rd!#", username="pony", password="aqew")

The above example produces a log like the below:

1970-01-01 12:34:56,789 - __main__ - DEBUG - Executing function login with args=['Arnold', '**********'] and kwargs={'username': 'pony', 'password': '**********'}

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

LogTracer-0.1.0.tar.gz (14.6 kB view details)

Uploaded Source

Built Distribution

LogTracer-0.1.0-py3-none-any.whl (15.1 kB view details)

Uploaded Python 3

File details

Details for the file LogTracer-0.1.0.tar.gz.

File metadata

  • Download URL: LogTracer-0.1.0.tar.gz
  • Upload date:
  • Size: 14.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.50.1 CPython/3.7.3

File hashes

Hashes for LogTracer-0.1.0.tar.gz
Algorithm Hash digest
SHA256 44293bba72969e3b6e26cea300afebf63434800ff360a77823365640fcc3278e
MD5 23e791cdf9c36aa8cbb4a2ea8f8f8759
BLAKE2b-256 6e8910eda2eb628b5fffe0e0df8cea742d069cffa5bb938aa8104a01567e1a5a

See more details on using hashes here.

File details

Details for the file LogTracer-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: LogTracer-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.50.1 CPython/3.7.3

File hashes

Hashes for LogTracer-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4b3f7e720d09cb24077e4f67f71c1b62dab42b011f18884f42e9ab4e7969f8af
MD5 1cd4773d6d11dd87a1c0ce0bfa7060ad
BLAKE2b-256 af5e13893bfb84392b7194b217ad5968dbd4189daf8552afed6e18ef27a06d92

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