A logger manager for Python programs
Project description
logcontrol: A logger manager for Python programs
- It provides:
Centralized control of log level (per-group)
Logging for exceptions and excessive runtime
- 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 for easy access to log levels 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()
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
Built Distribution
Hashes for logcontrol-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 365834a6c5fcd769895378835fab9d363f3b6c7ba5d6227d39b92bc719b88950 |
|
MD5 | 7aef6a54635c101bcd41c31741fca71f |
|
BLAKE2b-256 | 36ba5d4d93050e5f22fa3367344a1862c4485be5ed8d74c57e1915920b66f1b5 |