How do I get information about python logging printing in a shell script?

call the interface of python in the shell script, but python API prints the relevant information to the screen through the logging of python. I don"t know how to get these logging information in shell. Please advise. This is what the
code says:

import logging

......

logger = logging.getLogger("123")

......

def debug(msg):
    logger.setLevel(logging.DEBUG)
    debughandler = logging.StreamHandler()
    debughandler.setLevel(logging.DEBUG)
    fmt = "%(asctime)s - %(levelname)s - %(message)s"
    formatter = logging.Formatter(fmt)
    debughandler.setFormatter(formatter)
    logger.addHandler(debughandler)
    logger.debug(msg)
    logger.removeHandler(debughandler)

how is the information printed through logger.debug (msg) captured in shell?

Mar.21,2021

idea:
logger module has a way to write to a file, write the contents of log to a file, and then the shell script reads the log file.

the following excerpt is from https://cuiqingcai.com/6080.html

import logging
 
logging.basicConfig(level=logging.DEBUG,
                    filename='output.log',
                    datefmt='%Y/%m/%d %H:%M:%S',
                    format='%(asctime)s - %(name)s - %(levelname)s - %(lineno)d - %(module)s - %(message)s')
logger = logging.getLogger(__name__)
 
logger.info('This is a log info')
logger.debug('Debugging')
logger.warning('Warning exists')
logger.info('Finish')

here we specify the name of the output file as output.log, and the output format of the date, in which the format of the year, month and day is changed to% YBG% mBX% d. In addition, the output format format adds lineno and module information. After running, an output.log file will be generated

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1be838a-45e6f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1be838a-45e6f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?