updating with latest changes to CONFIG
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
from __future__ import annotations
|
||||
import sys
|
||||
from typing import Any, TypeVar, Type
|
||||
from typing import Any, TypeVar, Type, TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import logging
|
||||
|
||||
|
||||
config_inst_t = TypeVar('config_inst_t', bound='config.config.Config')
|
||||
config_inst_t = TypeVar('config_inst_t', bound='module.config.config.Config')
|
||||
|
||||
|
||||
def export(fn: callable) -> callable:
|
||||
@@ -35,3 +39,22 @@ def set_config(
|
||||
"""
|
||||
config_var = key.lower().replace('.', '_')
|
||||
setattr(config_inst, config_var, config_inst.get(key, default, cast))
|
||||
|
||||
|
||||
# Create function to print cached logged messages and reset
|
||||
def process_cached_logs(
|
||||
config_inst: Type[config_inst_t],
|
||||
logger: logging.Logger
|
||||
):
|
||||
"""Prints the cached messages from the CONFIG class and resets the cache.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
config_inst : Type[config_inst_t]
|
||||
Instance of the CONFIG class.
|
||||
logger : logging.Logger
|
||||
Instance of the active logger.
|
||||
"""
|
||||
for msg in config_inst.deferred_messages:
|
||||
logger.info(msg)
|
||||
config_inst.reset_log()
|
||||
|
||||
Reference in New Issue
Block a user