Skip to main content

logcontrol: A logger manager for Python programs

It provides:
  • Centralized control of log level (per-group)

Original use case:
  • Python GUI program containing many packages and modules

  • Each source file that logs creates a proper logger for use within that file

    • e.g. logger = logging.getLogger(__name__)

    • This allows a good logging hierarchy for control at a central point

  • I wanted to simplify enabling debug level for specific packages or groups

Installation:
  • pip install logcontrol

    (Tested for Python >=3.6.5 on Linux (Ubuntu) and Windows 7/10)

Usage:
  • example (where otherpackage and anotherpackage are example names):

    # imports of fictitious packages
    import otherpackage
    import anotherpackage
    
    import logging
    import logcontrol
    
    # Register loggers you wish to control.
    # You can have user-friendly names for the groups if you wish:
    logcontrol.register_logger(otherpackage.logger, group='Other Package')
    
    # Set output file for the root logger:
    logcontrol.set_log_file('main_log.txt')
    
    # Enable specific log levels per-group:
    logcontrol.set_level(logging.DEBUG, group='Other Package')
    
    # Make specific groups log to console while debugging:
    logcontrol.log_to_console(group='Other Package')
    
    # You can even disable or enable propagation per-group:
    logcontrol.disable_propagation(group='Other Package')
    logcontrol.enable_propagation(group='Other Package')
    
    # Loggers added to the same group will get the same configuration.
    # This would automatically set DEBUG level and attach the console logging handler:
    logcontrol.register_logger(anotherpackage.module.logger, group='Other Package')
    
    # You can get a dict of group names with level names (good for populating a debug/log control popup):
    logcontrol.group_level_names()
    
    # For convenience, the predefined log levels are available:
    #     - as integers via logcontrol.log_level_integers
    #     - as strings via logcontrol.log_level_strings
    #
    # This makes it easy to display them in a combo box for users to choose.

Metadata

Release files for logcontrol 0.2.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 logcontrol 0.2.1
File Size Uploaded
logcontrol-0.2.1.tar.gz 21.8 kB Details

Built distribution (wheel)

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

Total release size: 47.2 kB

Release files / logcontrol-0.2.1.tar.gz

Download URL logcontrol-0.2.1.tar.gz
Size 21.8 kB
Tags Source
SHA-256 checksum
How to use checksums
ec1ff8802fcf28841aff990d3c1941eb7334b2bf4bf8845118592ea2408b6207
BLAKE2b-256 checksum
How to use checksums
71fc00a16885f792b935eb6cacd1306ea69973d62859e6377da64c23c9e01997
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.9

Release files / logcontrol-0.2.1-py3-none-any.whl

Download URL logcontrol-0.2.1-py3-none-any.whl
Size 25.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
83a26882d78f1bc3928841ef05e8dd856270a3adf8c7e5f4c165656abf2d4024
BLAKE2b-256 checksum
How to use checksums
ef661d4bf80cd1ce85c2ddf8ae5ec41419796b17693c2aa9b1a7e67b2c96efe3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.9

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

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