def wrapped_func(*args, **kwargs): global _layer_level # Check if the logging level is at least DEBUG (for performance reasons) debug_output = log.getEffectiveLevel() <= logging.DEBUG if debug_output: # Indention for transformation layer indention = u"\u2502 " * _layer_level # For the input arguments, add indention to any lines after the first line from_str = str(args[0]).replace("\n", f"\n {indention}\u2502 ") to_str = str(args[1]).replace("\n", f"\n {indention}\u2502 ") # Log the description and the input arguments log.debug(f"{indention}{description}") log.debug(f"{indention}\u251c\u2500From: {from_str}") log.debug(f"{indention}\u251c\u2500To : {to_str}") # Increment the layer level to increase the indention for nested transformations _layer_level += 1 result = func(*args, **kwargs) if debug_output: # Decrement the layer level _layer_level -= 1 # For the output, add intention to any lines after the first line out_str = str(result).replace("\n", f"\n {indention} ") # Log the output log.debug(f"{indention}\u2514\u2500Out : {out_str}") return result
def test_is_level_configed(): """ Test to make sure that the logger follows the config: log_level """ config_level_numeric = level_to_numeric.get(config.get('logger', 'log_level')) assert log.getEffectiveLevel() == config_level_numeric