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


Python globalLogBeginner.beginLoggingTo方法代码示例

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


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

示例1: init

# 需要导入模块: from twisted.logger import globalLogBeginner [as 别名]
# 或者: from twisted.logger.globalLogBeginner import beginLoggingTo [as 别名]
def init(debug=False):
    debug_enabled = debug or os.environ.get('DEBUG', False)
    logging_level = logging.DEBUG if debug_enabled else logging.INFO

    logging.basicConfig(level=logging_level,
                        format='%(asctime)s [%(name)s] %(levelname)s %(message)s',
                        datefmt='%Y-%m-%d %H:%M:%S',
                        filemode='a')

    logging.getLogger('gnupg').setLevel(logging.WARN)
    logging.getLogger('gnupg').addFilter(PrivateKeyFilter())

    def formatter(event):
        try:
            event['log_time'] = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(event['log_time']))
            event['log_level'] = event['log_level'].name.upper()
            event['log_format'] = str(event['log_format']) + '\n' if event.get('log_format') else ''
            logstring = u'{log_time} [{log_namespace}] {log_level} ' + event['log_format']
            return logstring.format(**event)
        except Exception as e:
            return "Error while formatting log event: {!r}\nOriginal event: {!r}\n".format(e, event)

    observers = [FileLogObserver(sys.stdout, formatter)]
    globalLogBeginner.beginLoggingTo(observers) 
开发者ID:pixelated,项目名称:pixelated-user-agent,代码行数:26,代码来源:logger.py

示例2: start_logging

# 需要导入模块: from twisted.logger import globalLogBeginner [as 别名]
# 或者: from twisted.logger.globalLogBeginner import beginLoggingTo [as 别名]
def start_logging(out=_stdout, level='info'):
    """
    Start logging to the file-like object in ``out``. By default, this
    is stdout.
    """
    global _loggers, _observer, _log_level, _started_logging

    if level not in log_levels:
        raise RuntimeError(
            "Invalid log level '{0}'; valid are: {1}".format(
                level, ', '.join(log_levels)
            )
        )

    if _started_logging:
        return

    _started_logging = True

    _log_level = level
    set_global_log_level(_log_level)

    if out:
        _observer = _LogObserver(out)

    _observers = []
    if _observer:
        _observers.append(_observer)
    globalLogBeginner.beginLoggingTo(_observers) 
开发者ID:crossbario,项目名称:txaio,代码行数:31,代码来源:tx.py

示例3: init_logging

# 需要导入模块: from twisted.logger import globalLogBeginner [as 别名]
# 或者: from twisted.logger.globalLogBeginner import beginLoggingTo [as 别名]
def init_logging(configuration, program_name):
    """Given a basic configuration, set up logging."""
    logging.init_app_logging(configuration.log_dir, configuration.log_level,
                             progname=program_name,
                             quiet=configuration.quiet)
    # Initialize twisted logging, even if we don't explicitly use it,
    # because of leaky logs https://twistedmatrix.com/trac/ticket/8164
    globalLogBeginner.beginLoggingTo(
        [lambda _: None], redirectStandardIO=False, discardBuffer=True) 
开发者ID:CanonicalLtd,项目名称:landscape-client,代码行数:11,代码来源:deployment.py

示例4: twlog

# 需要导入模块: from twisted.logger import globalLogBeginner [as 别名]
# 或者: from twisted.logger.globalLogBeginner import beginLoggingTo [as 别名]
def twlog():
    from sys import stdout
    from twisted.logger import globalLogBeginner
    from twisted.logger import textFileLogObserver

    globalLogBeginner.beginLoggingTo([textFileLogObserver(stdout)]) 
开发者ID:gridsync,项目名称:gridsync,代码行数:8,代码来源:test_streamedlogs.py


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