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-25.4.1600.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-25.4.1600-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lumberstack-25.4.1600.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-25.4.1600.tar.gz
Algorithm Hash digest
SHA256 6a5e9819e26e26f5f5ef03072adafa9ac5c102b4e8fb78772539eba982ee8d5c
MD5 b40e7201d57d131a61835bef99b7409d
BLAKE2b-256 6372c94491e26ffca26f8d611c2fdae67e8ef6b8883f6d9b2fcfd19b5e2c1c89

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lumberstack-25.4.1600-py3-none-any.whl
Algorithm Hash digest
SHA256 0b031f73cd661264b3c6653bdd38a0a3032f12820366e47fad3fa4f7d97616f3
MD5 6099d25880c24396a2dbbafd78c4906f
BLAKE2b-256 76071483efad87c23dfe8d508d4a1f5f6111432bc2f7c74502bc8b0179d36b94

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