Skip to main content

Python Easy Logging (LOGG EZ)

Project description

loggez: Python EZ logging

Control logging levels with env vars and have a unique logger per name, for library purposes...

Only writes to stderr, no files or stuff. Use something else for file logging though you can hack this library too.

Installation

pip install loggez

Usage:

# run.py
from loggez import make_logger, loggez_logger
from loguru import logger

logger.info("loguru hi")
my_logger = make_logger("my_logger")
my_logger.add_file_handler("/path/to/logs.txt") # optional
my_logger.info("my_logger hi")
my_logger.debug("my_logger hi")
my_logger.debug2("my_logger hi")
my_logger.debug4("my_logger hi")

my_logger2 = make_logger("my_logger2")
my_logger2.info("my_logger2 hi")
my_logger2.debug("my_logger2 hi")
my_logger2.debug2("my_logger2 hi")
my_logger2.debug4("my_logger hi")

loggez_logger.info("loggez_logger hi")
loggez_logger.debug("loggez_logger hi")
loggez_logger.debug2("loggez_logger hi")
loggez_logger.debug4("loggez_logger hi")

Run with:

my_logger_LOGLEVEL=0 run.py
my_logger_LOGLEVEL=1 run.py
my_logger_LOGLEVEL=2 run.py
LOGGEZ_LOGLEVEL=4 run.py

Additional env vars:

  • my_logger_MESSAGE=...: see the default in loggez/loggez.py to control colors and stuff.
  • my_logger_INFO_MESSAGE=..., my_logger_DEBUG_MESSAGE=... etc.

Note: You can use also use the global predefined logger: from loggez import loggez_logger as logger; logger.info(...). Env variables are: LOGGEZ_LOGLEVEL=..., LOGGEZ_INFO_MESSAGE=.... etc.

That's all.

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

loggez-0.4.2.tar.gz (3.9 kB view details)

Uploaded Source

File details

Details for the file loggez-0.4.2.tar.gz.

File metadata

  • Download URL: loggez-0.4.2.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for loggez-0.4.2.tar.gz
Algorithm Hash digest
SHA256 4d476baf326ab16dc9b1a1fd71796d0eb4df366ddd7b562f54cda5fd670979dd
MD5 3ec79659b67070d631ee7e5d2f7b8d87
BLAKE2b-256 a93a7ed0a2b9b059d7407f2a0fdc6215c5e92415c1497201109878072e22a314

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