Simple logging service shared by all application modules
Project description
Singleton Logging Service
Logging service that is guaranteed to be a singleton. Based on Python logging, but every instantiation of LoggingService from any of an application's modules returns the same logger instance.
This API is more primitive than the hierarchical native logging module, but hopefully simple to use. One can log to a file, or to the console. One formatter is built in for info/debug/warn/err. Example:
my_module.py(290375): 2020-09-03 14:58:33,017;INFO: Start Epoch [1/50]
When first creating a LoggingService instance, the following options are available in the constructor:
logging_level=logging.INFO,
logfile=None,
msg_identifier=None,
rotating_logs=True,
log_size=1000000,
max_num_logs=500,
logger_name=None
After creation a logger instance may only be modified like this:
- my_logger.logging_level = logging.NEW_LEVEL
- my_logger.log_file = '/tmp/new_logfile'
where logging levels are the usual logging.INFO,
logging.WARN
, etc.
Code example:
from logging_service import LoggingService
self.log = LoggingService(logfile=logfile)
self.log.info("Constructing output file names...")
self.log.err("Constructing output file names...")
self.log.warn("Constructing output file names...")
self.log.debug("Constructing output file 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 logging_singleton-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 01d49040271f9bcf3104b11cef481510e217bcd9f0b17de9cba7de89801075dd |
|
MD5 | c6a9a008641540d92608ff8e47eb5605 |
|
BLAKE2b-256 | 065d8775795fdff2077299dcfa2bd4d4170f909b8785052b0b616d3062cc3a26 |