日志记录抛出的调试消息,尽管设置为级别警告

时间:2018-11-23 14:34:19

标签: python logging

尽管我收到调试级别警告,但仍收到调试级别日志记录消息-这就是我所期望的。也许有人知道怎么了...

这是我代码的相关部分。

def setLogfileDebuglevel(val):
    """set logging level and message format"""
    if val==True:
        print ("debug level")
        logging.basicConfig(level=logging.DEBUG,
                        filename=THISPATH + "/wawi-uploader.log",
                        style="{",
                        format="{asctime} [{funcName}: {levelname:8}] {message}",
                        datefmt="%H:%M:%S")
elif val==False:
     print ("warning level")
    logging.basicConfig(level=logging.WARNING,
                        filename=THISPATH + "/wawi-uploader.log",
                        style="{",
                        format="{asctime} [{funcName}: {levelname:8}] {message}",
                        datefmt="%H:%M:%S")

class UploaderGUI(tkinter.Frame):
    def __init__(self, master=None):
        """Initialize main window and GUI objects"""
        super().__init__(master)
        self.pack()
        self.menuBar = tkinter.Menu(self.master)
        self.fillMenuBar()
        self.master.config(menu=self.menuBar)
        self._args = self.argparser()
        self._extensions = self._args.extensions
        setLogfileDebuglevel(self._args.debug) 
        logging.debug(self._args)  
        # here debug msg are logged although I an on level warning

print ("warning level")是一项测试,测试我的参数是否正确-正确,我处于警告级别。无论如何,程序都会不断记录self._args

0 个答案:

没有答案