inspect.stack()

inspect.stack()

#  -----------------------------------------  #
def _get_funcname():
    return inspect.stack()[1][3]

def sample():
    logger = logging.getLogger(__name__)
    logger.debug('begin ------> {}()'.format(sys._getframe().f_code.co_name))
    logger.debug('begin ------> {}()'.format(inspect.stack()[0][3]))
    logger.debug('begin ------> {}()'.format(_get_funcname()))
    
#============================================================
#DateTime : Sunday, June 10, 2018 4:32:51 PM
#CmdLine  : python G:\workplace\py\sandbox\inspect_sample.py run
#============================================================
[2018/06/10 16:32:51][DEBUG](inspect_sample.py:45:process) 
{'--help': False,
 '--version': False,
 'run': True}
[2018/06/10 16:32:51][DEBUG](inspect_sample.py:53:process) run --------------------
[2018/06/10 16:32:51][DEBUG](inspect_sample.py:35:sample) begin ------> sample()
[2018/06/10 16:32:51][DEBUG](inspect_sample.py:36:sample) begin ------> sample()
[2018/06/10 16:32:51][DEBUG](inspect_sample.py:37:sample) begin ------> sample()

// --- end of blog