python日志更改格式内部功能

时间:2017-03-28 15:32:04

标签: python logging

我有一个调用一些长函数的python脚本。我想更改函数内的日志格式。

类似的东西:

def funz1():
  logging.basicConfig(format='%(asctime)s FUNZ1:%(levelname)s:% message)s',
  x = 3
  logging.info('x is defined')
  return


def runner()
    logging.basicConfig(format='%(asctime)s Runner:%(levelname)s: %(message)s',
   z = 10
   logging.info("z is defined") # RUNNER format
   funz1() # The generated log must be FUNZ1 format
   v = 20
   logging.info("v is defined")  # RUNNER format

编辑: 除了格式我还要更改loglevel

0 个答案:

没有答案