line = lines[0]
indentation_level = line.find(line.lstrip())
logger.debug('{i} [{m}]'.format(i='.' * indentation_level, m=msg))

def foo():
    debug('Hi Mom')
for i in range(1):
    debug("Now we're cookin")
if __name__ == '__main__':
    logging.basicConfig(level=logging.DEBUG)
foo()
Python indentation \ context level to log prefix length 