Skip to main content

A simple logger for python

Project description

Simple Python logger

A simple logger for console/file logging with duplicate logs filter support

Release new version

requirements

  • Export GitHub token
export GITHUB_TOKEN=<your_github_token>

Run the following once (execute outside repository dir for example ~/):

sudo npm install --global release-it
npm install --save-dev @release-it/bumper

usage

  • Create a release
git pull
release-it # Follow the instructions

Usage

from simple_logger.logger import get_logger
logger = get_logger(name=__name__, level=logging.DEBUG, filename="my-log.log")
logger.info("This is INFO log")
logger.success("This is SUCCESS log")

TOKEN = "1234"
PASS = "pass123"
logger.hash(f"This is my password: {PASS} and this is my token {TOKEN}", hash=[PASS, TOKEN])
>>> This is INFO log
>>> This is SUCCESS log
>>> This is my password: ***** and this is my token *****


# mask sensitive data default words are ["password", "token", "apikey", "secret"]
# Pass mask_sensitive_patterns = ["custom_pattern", "another_pattern"] to change the default patterns to match
hashed_logger = get_logger(name=__name__, mask_sensitive=True)
hashed_logger.info(er = get"This is my password: pass123")
hashed_logger.info(er = get"This is my token tok456!")
hashed_logger.info(er = get"This is my apikey - api#$789")
hashed_logger.info(er = get"This is my secret -> sec1234abc")
>>> This is my password *****
>>> This is my token *****
>>> This is my apikey *****
>>> This is my secret *****

# Force colored output in non-TTY environments (Docker, CI/CD)
# Option 1: Use FORCE_COLOR environment variable
import os
os.environ["FORCE_COLOR"] = "1"  # or set in Dockerfile/docker-compose.yml
logger = get_logger(name=__name__)

# Option 2: Use force_color parameter
logger = get_logger(name=__name__, force_color=True)

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

python_simple_logger-2.0.18.tar.gz (9.7 kB view details)

Uploaded Source

File details

Details for the file python_simple_logger-2.0.18.tar.gz.

File metadata

  • Download URL: python_simple_logger-2.0.18.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for python_simple_logger-2.0.18.tar.gz
Algorithm Hash digest
SHA256 7b1fc3c9389d6e68a37527c2570a5050996f7c5b7af1b62baf661c112b76d6af
MD5 a47289a4c8f5f0035c8c100bd2cf13ee
BLAKE2b-256 ef7e6eeae8c7affa2c4c1aa765a5c6a5ad15914184654e355e66d04a3cbac2f9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page