Skip to main content

Tests Lint Quality codecov PyPI version Python Platform License PRs Welcome

MaskerLoggerTitle

Masker Logger

Keep Your logs safe! This formatter ensures the security of your logs and prevents sensitive data leaks. For example - Using this Formatter will print this line: logger.info(f'Dont Give Your {secrets} away') like this: Dont Give Your ****** away

Getting started

This formatter utilizes the standard logging.Formatter module. Before printing each record to any destination (file, stdout, etc.), it ensures sensitive data is masked with asterisks to prevent leaks.

Requirements

MaskerLogger Version Python Version
1.0.0+ 3.10 - 3.13
< 1.0.0 3.9 - 3.13

Install the library

pip install maskerlogger

Basic Usage

Like any formatter - just init your logger handler with the MaskerLogger formatter.

from maskerlogger import MaskerFormatter
logger = logging.getLogger('logger')
logger.setLevel(logging.DEBUG)
handler = logging.StreamHandler()
handler.setFormatter(
    MaskerFormatter("%(asctime)s %(name)s %(levelname)s %(message)s"))
logger.addHandler(handler)

skip masking

If, for some reason, you want to disable masking on a specific log line, use the SKIP_MASK mechanism.

from maskerlogger import MaskerFormatter, SKIP_MASK
...
...
logger.info('Line you want to skip', extra=SKIP_MASK)

redact

Here’s a rewritten version suitable for inclusion in a README.md file:


Partial Masking of Secrets

If you prefer to mask only a portion of a secret (rather than its entire length), you can set the redact parameter in the formatter. The redact parameter specifies the percentage of the secret to be masked.

Here’s an example of how to use it:

handler.setFormatter(
    MaskerFormatter("%(asctime)s %(name)s %(levelname)s %(message)s",
                    redact=30))

In this example, 30% of the secret will be masked. Adjust the redact value as needed to suit your requirements.

The Config File

Here's where the magic happens! Our tool is built upon the powerful Gitleaks tool, leveraging its default configuration to scan for sensitive data leaks in repositories. You can find the default configuration here

Use custom config file

To create and use your own config file, set the path when initializing the formatter:

handler.setFormatter(
    MaskerFormatter("%(asctime)s %(name)s %(levelname)s %(message)s",
                    regex_config_path="your/config/gitleaks.toml"))

Good luck!

Brought to you by OX Security

Metadata

Release files for maskerlogger 1.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for maskerlogger 1.1.1
File Size Uploaded
maskerlogger-1.1.1.tar.gz 30.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for maskerlogger 1.1.1
File Interpreter ABI Platform
maskerlogger-1.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 60.4 kB

Release files / maskerlogger-1.1.1.tar.gz

Download URL maskerlogger-1.1.1.tar.gz
Size 30.3 kB
Tags Source
SHA-256 checksum
How to use checksums
67523b94dc018738cfb287b5ec9d65af075b812d46669c7cc00835801eae181c
BLAKE2b-256 checksum
How to use checksums
43f6130b4f511263c1eb56615df36e39e0a197078f58676dfd1da7986a8abe4c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2025.

Transparency log

Release files / maskerlogger-1.1.1-py3-none-any.whl

Download URL maskerlogger-1.1.1-py3-none-any.whl
Size 30.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fcc9841b949c527320dfc93a620f259e528c29d1bf4e5c019a26ce1c1fc6b1b0
BLAKE2b-256 checksum
How to use checksums
c0ef167a0bb83af6b877ab2f341d7a83792d4edf38c7487e062abbf956083e0f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2025.

Transparency log
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page