• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python std_err_override.LogWriter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中std_err_override.LogWriter的典型用法代码示例。如果您正苦于以下问题:Python LogWriter类的具体用法?Python LogWriter怎么用?Python LogWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: setup_logger

def setup_logger(log_config, logpath):
    logging.config.fileConfig(log_config)
    #need to wait for Python 2.7 for this..
    #logging.captureWarnings(True)
    logger = logging.getLogger()
    LogWriter.override_std_err(logger)
    logfile = unicode(logpath)
    setup_logging(logfile)
    log = get_logger()
    return log
开发者ID:Robbt,项目名称:Airtime,代码行数:10,代码来源:launcher.py


示例2: AirtimeMediaConfig

    logger.debug("sys default encoding %s", sys.getdefaultencoding())
    logger.debug("After %s", locale.nl_langinfo(locale.CODESET))

    if current_locale_encoding not in ['utf-8', 'utf8']:
        logger.error("Need a UTF-8 locale. Currently '%s'. Exiting..." % current_locale_encoding)
        sys.exit(1)

# configure logging
try:
    logging.config.fileConfig("logging.cfg")

    #need to wait for Python 2.7 for this..
    #logging.captureWarnings(True)

    logger = logging.getLogger()
    LogWriter.override_std_err(logger)

except Exception, e:
    print 'Error configuring logging: ', e
    sys.exit(1)

logger.info("\n\n*** Media Monitor bootup ***\n\n")


try:
    configure_locale()

    config = AirtimeMediaConfig(logger)
    api_client = apc.AirtimeApiClient()
    api_client.register_component("media-monitor")
开发者ID:AtomLaw,项目名称:Airtime,代码行数:30,代码来源:mm1.py


示例3: main

def main(global_config, api_client_config, log_config,
        index_create_attempt=False):
    for cfg in [global_config, api_client_config]:
        if not os.path.exists(cfg): raise NoConfigFile(cfg)
    # MMConfig is a proxy around ConfigObj instances. it does not allow
    # itself users of MMConfig instances to modify any config options
    # directly through the dictionary. Users of this object muse use the
    # correct methods designated for modification
    try: config = MMConfig(global_config)
    except NoConfigFile as e:
        print("Cannot run mediamonitor2 without configuration file.")
        print("Current config path: '%s'" % global_config)
        sys.exit(1)
    except Exception as e:
        print("Unknown error reading configuration file: '%s'" % global_config)
        print(str(e))


    logging.config.fileConfig(log_config)

    #need to wait for Python 2.7 for this..
    #logging.captureWarnings(True)

    logger = logging.getLogger()
    LogWriter.override_std_err(logger)
    logfile = unicode( config['logpath'] )
    setup_logging(logfile)
    log = get_logger()

    if not index_create_attempt:
        if not os.path.exists(config['index_path']):
            log.info("Attempting to create index file:...")
            try:
                with open(config['index_path'], 'w') as f: f.write(" ")
            except Exception as e:
                log.info("Failed to create index file with exception: %s" % str(e))
            else:
                log.info("Created index file, reloading configuration:")
                main( global_config,  api_client_config, log_config,
                        index_create_attempt=True )
    else:
        log.info("Already tried to create index. Will not try again ")

    if not os.path.exists(config['index_path']):
        log.info("Index file does not exist. Terminating")

    log.info("Attempting to set the locale...")

    try:
        mmp.configure_locale(mmp.get_system_locale())
    except FailedToSetLocale as e:
        log.info("Failed to set the locale...")
        sys.exit(1)
    except FailedToObtainLocale as e:
        log.info("Failed to obtain the locale form the default path: \
                '/etc/default/locale'")
        sys.exit(1)
    except Exception as e:
        log.info("Failed to set the locale for unknown reason. \
                Logging exception.")
        log.info(str(e))

    watch_syncer = WatchSyncer(signal='watch',
                               chunking_number=config['chunking_number'],
                               timeout=config['request_max_wait'])

    apiclient = apc.AirtimeApiClient.create_right_config(log=log,
            config_path=api_client_config)

    ReplayGainUpdater.start_reply_gain(apiclient)

    sdb = AirtimeDB(apiclient)

    manager = Manager()

    airtime_receiver = AirtimeMessageReceiver(config,manager)
    airtime_notifier = AirtimeNotifier(config, airtime_receiver)

    store = apiclient.setup_media_monitor()
    airtime_receiver.change_storage({ 'directory':store[u'stor'] })

    for watch_dir in store[u'watched_dirs']:
        if not os.path.exists(watch_dir):
            # Create the watch_directory here
            try: os.makedirs(watch_dir)
            except Exception as e:
                log.error("Could not create watch directory: '%s' \
                        (given from the database)." % watch_dir)
        if os.path.exists(watch_dir):
            airtime_receiver.new_watch({ 'directory':watch_dir }, restart=True)

    bs = Bootstrapper( db=sdb, watch_signal='watch' )

    ed = EventDrainer(airtime_notifier.connection,
            interval=float(config['rmq_event_wait']))

    # Launch the toucher that updates the last time when the script was
    # ran every n seconds.
    # TODO : verify that this does not interfere with bootstrapping because the
    # toucher thread might update the last_ran variable too fast
#.........这里部分代码省略.........
开发者ID:flowfeeler,项目名称:Airtime,代码行数:101,代码来源:mm2.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python msg.Bool类代码示例发布时间:2022-05-27
下一篇:
Python stdStuff.objFileToList函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap