Skip to main content

A simple abstraction of the logging package

Project description

Lumberstack

Global init in __main__

Example to determine log file name

if helpers.am_debugging:
  log_file_name = f'{config.log_file.rstrip(".log")}_debug.log'
  if os.path.exists(log_file_name):
    os.remove(log_file_name)
else:
  log_file_name = (f'{config.log_file.rstrip(".log")}_'
                   f'{str(datetime.now() if helpers.am_debugging else datetime.utcnow()).split(".", 1)[0].replace(":", ".").replace(" ", "_")}'
                    '.log')

Only run global_init once in __main__

Lumberstack.global_init(timezone=time.localtime if helpers.am_debugging else time.gmtime, log_filename=log_file_name, log_level=config.log_level, console_output=True)

Add a custom handler during global init

fh = logging.FileHandler(filename='new.log')
Lumberstack.global_init(log_level=config.log_level, custom_handlers=[fh])

Update log levels of imported libraries using the logging package

Lumberstack.update_library_levels(libraries=['requests', 'urllib3'], log_level=config.lib_log_level)
Lumberstack.update_library_levels(libraries=['cli.azure.cli.core', 'cli.knack.cli', 'msal.authority', 'msal.application', 'msal.telemetry'], log_level=config.az_log_level)

Local init for each file/module

logger = Lumberstack()
logger.info(f'{APP_NAME} - {APP_DESCRIPTION}')

Log levels use the logging package values

  • CRITICAL = 50
  • FATAL = CRITICAL
  • ERROR = 40
  • WARNING = 30
  • WARN = WARNING
  • INFO = 20
  • DEBUG = 10
  • NOTSET = 0

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

lumberstack-26.4.1400.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lumberstack-26.4.1400-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file lumberstack-26.4.1400.tar.gz.

File metadata

  • Download URL: lumberstack-26.4.1400.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.1

File hashes

Hashes for lumberstack-26.4.1400.tar.gz
Algorithm Hash digest
SHA256 32281f1f992b0d83b1feb1c4baedbfca27a3f5a4a21c6add13eac2af6dee5d0d
MD5 a824e6f34b46c932dc32de75c603025e
BLAKE2b-256 e877ebddb868fb7be26ace979ecdc58ed4ee0290e7b44b8e918294b761f89a26

See more details on using hashes here.

File details

Details for the file lumberstack-26.4.1400-py3-none-any.whl.

File metadata

File hashes

Hashes for lumberstack-26.4.1400-py3-none-any.whl
Algorithm Hash digest
SHA256 689726cecaad27d9586c1e2806ff10b0619787b37bee6839b02e013a10434391
MD5 e99b593f03167db9ee3b1d0c66d23326
BLAKE2b-256 3b76336f0d00a09a721d6acd93b04851f5303d3be2789c96942ef0a00015bdc0

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