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


Python logging.getLogger方法代码示例

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


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

示例1: setup_python_logging

# 需要导入模块: from google.cloud import logging [as 别名]
# 或者: from google.cloud.logging import getLogger [as 别名]
def setup_python_logging(self):
        """Configures Python logging system

        Python logs are sent to STDOUT and STDERR by default.  In GCF, these
        logs are associated on execution_id.
        """
        if os.getenv('DEBUG'):
            level = logging.DEBUG
        else:
            level = logging.INFO
        # Make googleapiclient less noisy.
        # See https://github.com/googleapis/google-api-python-client/issues/299
        api_logger = logging.getLogger('googleapiclient')
        api_logger.setLevel(logging.ERROR)
        # Set level of our logger.
        log = logging.getLogger(self.LOGNAME)
        log.setLevel(level)
        return log 
开发者ID:GoogleCloudPlatform,项目名称:professional-services,代码行数:20,代码来源:main.py

示例2: suppress_unwanted_warnings

# 需要导入模块: from google.cloud import logging [as 别名]
# 或者: from google.cloud.logging import getLogger [as 别名]
def suppress_unwanted_warnings():
  """Suppress unwanted warnings."""
  # See https://github.com/googleapis/google-api-python-client/issues/299
  logging.getLogger('googleapiclient.discovery_cache').setLevel(logging.ERROR) 
开发者ID:google,项目名称:clusterfuzz,代码行数:6,代码来源:logs.py

示例3: configure_appengine

# 需要导入模块: from google.cloud import logging [as 别名]
# 或者: from google.cloud.logging import getLogger [as 别名]
def configure_appengine():
  """Configure logging for App Engine."""
  logging.getLogger().setLevel(logging.INFO)

  if os.getenv('LOCAL_DEVELOPMENT') or os.getenv('PY_UNITTESTS'):
    return

  import google.cloud.logging
  client = google.cloud.logging.Client()
  handler = client.get_default_handler()
  logging.getLogger().addHandler(handler) 
开发者ID:google,项目名称:clusterfuzz,代码行数:13,代码来源:logs.py

示例4: configure

# 需要导入模块: from google.cloud import logging [as 别名]
# 或者: from google.cloud.logging import getLogger [as 别名]
def configure(name, extras=None):
  """Set logger. See the list of loggers in bot/config/logging.yaml.
  Also configures the process to log any uncaught exceptions as an error.
  |extras| will be included by emit() in log messages."""
  suppress_unwanted_warnings()

  if _is_running_on_app_engine():
    configure_appengine()
    return

  if _console_logging_enabled():
    logging.basicConfig()
  else:
    config.dictConfig(get_logging_config_dict(name))

  logger = logging.getLogger(name)
  logger.setLevel(logging.INFO)
  set_logger(logger)

  # Set _default_extras so they can be used later.
  if extras is None:
    extras = {}
  global _default_extras
  _default_extras = extras

  # Install an exception handler that will log an error when there is an
  # uncaught exception.
  sys.excepthook = uncaught_exception_handler 
开发者ID:google,项目名称:clusterfuzz,代码行数:30,代码来源:logs.py

示例5: get_logger

# 需要导入模块: from google.cloud import logging [as 别名]
# 或者: from google.cloud.logging import getLogger [as 别名]
def get_logger():
  """Return logger. We need this method because we need to mock logger."""
  if _logger:
    return _logger

  if _is_running_on_app_engine():
    # Running on App Engine.
    set_logger(logging.getLogger())

  elif _console_logging_enabled():
    # Force a logger when console logging is enabled.
    configure('root')

  return _logger 
开发者ID:google,项目名称:clusterfuzz,代码行数:16,代码来源:logs.py

示例6: _configure_logging

# 需要导入模块: from google.cloud import logging [as 别名]
# 或者: from google.cloud.logging import getLogger [as 别名]
def _configure_logging(verbose=True, stackdriver_logging=False):
  """Basic logging configuration.

  Args:
    verbose: enable verbose logging
    stackdriver_logging: enable Stackdriver logging
  """
  logging.basicConfig(level=logging.ERROR)
  level = logging.DEBUG if verbose else logging.INFO
  logging.getLogger(_LOGGER.name).setLevel(level)
  warnings.filterwarnings('ignore', r'.*end user credentials.*', UserWarning)
  if stackdriver_logging:
    import google.cloud.logging
    client = google.cloud.logging.Client()
    client.setup_logging(log_level=level) 
开发者ID:GoogleCloudPlatform,项目名称:professional-services,代码行数:17,代码来源:gce-quota-sync.py

示例7: __init__

# 需要导入模块: from google.cloud import logging [as 别名]
# 或者: from google.cloud.logging import getLogger [as 别名]
def __init__(self, handler=None, transport=sync.SyncTransport):
        self.logger = logging.getLogger()

        if handler is None:
            handler = logging.StreamHandler()

        self.handler = handler
        self.logger.addHandler(handler)
        self.logger.setLevel(logging.INFO)
        self.transport = transport(self) 
开发者ID:census-instrumentation,项目名称:opencensus-python,代码行数:12,代码来源:logging_exporter.py

示例8: setup_logging

# 需要导入模块: from google.cloud import logging [as 别名]
# 或者: from google.cloud.logging import getLogger [as 别名]
def setup_logging(app):
    log_formatter = logger.Formatter(
            '%(asctime)s %(levelname)8s [%(filename)s:%(lineno)d] '
            '%(client)s %(message)s')
    # log to files unless on AppEngine
    if not on_appengine():
        # Main logger
        if not (app.debug or app.config.get('TESTING')):
            handler = logging.FileHandler(
                app.config.get('LOGFILE', '/tmp/scoreboard.wsgi.log'))
            handler.setLevel(logging.INFO)
            handler.setFormatter(log_formatter)
            app.logger.addHandler(handler)
        else:
            app.logger.handlers[0].setFormatter(log_formatter)

        # Challenge logger
        handler = logging.FileHandler(
            app.config.get('CHALLENGELOG', '/tmp/scoreboard.challenge.log'))
        handler.setLevel(logging.INFO)
        handler.setFormatter(logger.Formatter(
            '%(asctime)s %(client)s %(message)s'))
        local_logger = logging.getLogger('scoreboard')
        local_logger.addHandler(handler)
        app.challenge_log = local_logger
    else:
        app.challenge_log = app.logger
        try:
            import google.cloud.logging
            from google.cloud.logging import handlers
            client = google.cloud.logging.Client()
            client.setup_logging()
            handler = handlers.CloudLoggingHandler(client)
            app.logger.addHandler(handler)
            handler.setLevel(logging.INFO)
            return app
        except ImportError as ex:
            logging.error('Failed setting up logging: %s', ex)
        if not app.logger.handlers:
            app.logger.addHandler(flask_logging.default_handler)
            app.logger.handlers[0].setFormatter(log_formatter)
            logging.getLogger().handlers[0].setFormatter(log_formatter)

    return app 
开发者ID:google,项目名称:ctfscoreboard,代码行数:46,代码来源:main.py


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