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


Python logging.INFO属性代码示例

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


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

示例1: setup_python_logging

# 需要导入模块: from google.cloud import logging [as 别名]
# 或者: from google.cloud.logging import INFO [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: get_handler_config

# 需要导入模块: from google.cloud import logging [as 别名]
# 或者: from google.cloud.logging import INFO [as 别名]
def get_handler_config(filename, backup_count):
  """Get handler config."""
  root_directory = os.getenv('ROOT_DIR')
  file_path = os.path.join(root_directory, filename)
  max_bytes = 0 if _is_local() else LOCAL_LOG_LIMIT

  return {
      'class': 'logging.handlers.RotatingFileHandler',
      'level': logging.INFO,
      'formatter': 'simple',
      'filename': file_path,
      'maxBytes': max_bytes,
      'backupCount': backup_count,
      'encoding': 'utf8',
  } 
开发者ID:google,项目名称:clusterfuzz,代码行数:17,代码来源:logs.py

示例3: get_logging_config_dict

# 需要导入模块: from google.cloud import logging [as 别名]
# 或者: from google.cloud.logging import INFO [as 别名]
def get_logging_config_dict(name):
  """Get config dict for the logger `name`."""
  logging_handler = {
      'run_bot': get_handler_config('bot/logs/bot.log', 3),
      'run': get_handler_config('bot/logs/run.log', 1),
      'run_heartbeat': get_handler_config('bot/logs/run_heartbeat.log', 1),
      'heartbeat': get_handler_config('bot/logs/heartbeat.log', 1),
      'run_fuzzer': get_handler_config('bot/logs/run_fuzzer.log', 1),
      'run_testcase': get_handler_config('bot/logs/run_testcase.log', 1),
  }

  return {
      'version': 1,
      'disable_existing_loggers': False,
      'formatters': {
          'simple': {
              'format': ('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
          }
      },
      'handlers': {
          'handler': logging_handler[name],
          'fluentd': {
              'class': 'metrics.logs.JsonSocketHandler',
              'level': logging.INFO,
              'host': '127.0.0.1',
              'port': 5170,
          }
      },
      'loggers': {
          name: {
              'handlers': ['handler']
          }
      },
      'root': {
          'level': logging.INFO,
          'handlers': ['fluentd']
      }
  } 
开发者ID:google,项目名称:clusterfuzz,代码行数:40,代码来源:logs.py

示例4: configure_appengine

# 需要导入模块: from google.cloud import logging [as 别名]
# 或者: from google.cloud.logging import INFO [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

示例5: configure

# 需要导入模块: from google.cloud import logging [as 别名]
# 或者: from google.cloud.logging import INFO [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

示例6: log

# 需要导入模块: from google.cloud import logging [as 别名]
# 或者: from google.cloud.logging import INFO [as 别名]
def log(message, level=logging.INFO, **extras):
  """Logs the message to a given log file."""
  emit(level, message, **extras) 
开发者ID:google,项目名称:clusterfuzz,代码行数:5,代码来源:logs.py

示例7: filter

# 需要导入模块: from google.cloud import logging [as 别名]
# 或者: from google.cloud.logging import INFO [as 别名]
def filter(self, rec):
        return rec.levelno in (logging.DEBUG, logging.INFO) 
开发者ID:GoogleCloudPlatform,项目名称:professional-services,代码行数:4,代码来源:main.py

示例8: log_struct

# 需要导入模块: from google.cloud import logging [as 别名]
# 或者: from google.cloud.logging import INFO [as 别名]
def log_struct(self, msg: str, struct: dict = {}, **kw):
        """Logs a structured message

        Annotated with metadata about the event being handled.

        Args:
          msg: Text message to log via message key in log structure.
          struct: Additional key/value attributes to log in the log structure.
          **kw: (optional) additional keyword arguments for the entry.  See
            :class:`~google.cloud.logging.entries.LogEntry`.
        """
        # Note: If the log name has a prefix of
        # `cloudfunctions.googleapis.com/cloud-functions` then message will not
        # be parsed from jsonPayload in the Console UI.
        log_name = (
            'projects/{}/logs/reports%2F{}'
        ).format(self.function_project, self.function_name)
        jsonPayload = {'vm_uri': self.vm_uri}
        jsonPayload.update(struct)
        resource_labels = {
            'function_name': self.function_name,
            'project_id': self.function_project,
            'region': self.function_region,
        }
        resource = Resource(labels=resource_labels, type='cloud_function')
        log_entry = {
            'log_name': log_name,
            'labels': {
                'event_id': self.event_id,
            },
            'severity': 'INFO',
            'resource': resource,
        }
        log_entry.update(kw)
        jsonPayload['message'] = msg
        self.cloud_log.log_struct(info=jsonPayload, **log_entry) 
开发者ID:GoogleCloudPlatform,项目名称:professional-services,代码行数:38,代码来源:main.py

示例9: _configure_logging

# 需要导入模块: from google.cloud import logging [as 别名]
# 或者: from google.cloud.logging import INFO [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

示例10: __init__

# 需要导入模块: from google.cloud import logging [as 别名]
# 或者: from google.cloud.logging import INFO [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

示例11: setup_logging

# 需要导入模块: from google.cloud import logging [as 别名]
# 或者: from google.cloud.logging import INFO [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.INFO属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。