• logging日志管理--将日志打印在屏幕上


    # -*- coding: cp936 -*-
    # test.py
    #http://blog.chinaunix.net/uid-27571599-id-3492860.html
    #logging日志管理

    #将日志打印在屏幕上 import logging

    #日志记录的格式 log_format
    ='[%(asctime)s] [%(filename)s] [%(levelname)s] %(message)s'

    #设置日志输出格式和级别 logging.basicConfig(format=log_format,datetime='%Y-%m-%d %H:%M:%S',level=logging.DEBUG) logging.debug('this message debug')
    #输出结果: #[2015-10-20 09:58:14,631] [new.py] [DEBUG] this message debug
    #下面逐条解释 #log_format:定义日志格式的一个变量,即需要显示的日志信息有哪些 #%(filename)s:脚本名字,如:new.py #%(levelname)s:日志级别的名字格式 #%(levelno)s:日志级别的数字表示 #%(name)s:日志名字,如:root #%(funcName)s:函数名字,如:module #%(asctime)s:日志时间,可以使用datefmt定义时间格式 #%(pathname)s:该运行脚本的绝对路径 #%(module)s:模块的名字,如:new #%(threadName)s:线程的名字 #%(thread)s: # %p:
  • 相关阅读:
    AutoIT练习
    AutoIT键盘鼠标模拟组件
    javascript class 定义
    JIRA
    vs 命令窗口 常用命令
    jquery 获取参数 plugin
    THE VALUE OF TIME
    哈佛图书馆的二十条训言
    优秀javascript js组件集锦
    UVA 11205 The broken pedometer
  • 原文地址:https://www.cnblogs.com/dengyg200891/p/4893893.html
Copyright © 2020-2023  润新知