当前位置: 首页>>代码示例>>Python>>正文


Python Logging.initialize_logging方法代码示例

本文整理汇总了Python中Logging.initialize_logging方法的典型用法代码示例。如果您正苦于以下问题:Python Logging.initialize_logging方法的具体用法?Python Logging.initialize_logging怎么用?Python Logging.initialize_logging使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Logging的用法示例。


在下文中一共展示了Logging.initialize_logging方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test2

# 需要导入模块: import Logging [as 别名]
# 或者: from Logging import initialize_logging [as 别名]
def test2(argv=None):
    import Logging
    from optparse import OptionParser
    
    if argv is None:
        argv = sys.argv[1:]
    # Setup command line options
    parser = OptionParser("usage: %prog [options]")
    parser.add_option("-l", "--logdir", dest="logdir", default=".", help="log DIRECTORY (default ./)")
    parser.add_option("-m", "--module", dest="module", default="project", help="module/project name from where logging")    
    parser.add_option("-f", "--logfile", dest="logfile", default="project.log", help="log file (default project.log)")    
    parser.add_option("-v", "--loglevel", dest="loglevel", default="debug", help="logging level (debug, info, error)")
    parser.add_option("-q", "--quiet", action="store_true", dest="quiet", help="do not log to console")    
    parser.add_option("-n", "--filequiet", action="store_true", dest="fquiet", help="do not log to file")
    parser.add_option("-c", "--clean", dest="clean", action="store_true", default=False, help="remove old log file")
    
    # Process command line options
    (options, args) = parser.parse_args(argv)

    # Setup logger format and output locations
    log = Logging.initialize_logging(options)

    # Examples
    log.error("This is an error message.")
    log.info("This is an info message.")
    log.debug("This is a debug message.")
开发者ID:dksr,项目名称:REMIND,代码行数:28,代码来源:Logging.py

示例2: __init__

# 需要导入模块: import Logging [as 别名]
# 或者: from Logging import initialize_logging [as 别名]
 def __init__(self):
     #self.log = Logging_Manager().getLogger({'module':'Hel'})
     options = {'fquiet':              None, 
                 'loglevel':           'info', 
                 'quiet':               None, 
                 'module':              "", 
                 'logdir':              '/tmp/', 
                 'clean':               False, 
                 'rotating_log':        True,
                 'rotating_file_mode': "a",
                 'maxBytes':            0,
                 'backupCount':         10,
                 'logfile':            'project.log'}
     options = attrdict(options)
     self.log = Logging.initialize_logging(options)
     self.log.info("START TIME: " + time.asctime())
     self.log.error('Creating new instance of  Hel')
开发者ID:dksr,项目名称:REMIND,代码行数:19,代码来源:Logging.py


注:本文中的Logging.initialize_logging方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。