Source code for python_utils.print_msg

#!/usr/bin/env python3

import traceback
import sys
from textwrap import dedent, indent
from logging import getLogger








[docs]def log_info(info_msg, verbose=True, dedent_=True): """Function to print information message using the logging module. This function should not be used if python logging has not been initialized. Args: info_msg : info message to print verbose : set to False to silence printing dedent_ : set to False to disable "dedenting" (print string as-is) Returns: None """ # "sys._getframe().f_back.f_code.co_name" returns the name of the calling function logger = getLogger(sys._getframe().f_back.f_code.co_name) if verbose: if dedent_: logger.info(indent(dedent(info_msg), " ")) else: logger.info(info_msg)