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


Python logging.LoggerAdapter方法代码示例

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


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

示例1: setUp

# 需要导入模块: import logging [as 别名]
# 或者: from logging import LoggerAdapter [as 别名]
def setUp(self):
        super(LoggerAdapterTest, self).setUp()
        old_handler_list = logging._handlerList[:]

        self.recording = RecordingHandler()
        self.logger = logging.root
        self.logger.addHandler(self.recording)
        self.addCleanup(self.logger.removeHandler, self.recording)
        self.addCleanup(self.recording.close)

        def cleanup():
            logging._handlerList[:] = old_handler_list

        self.addCleanup(cleanup)
        self.addCleanup(logging.shutdown)
        self.adapter = logging.LoggerAdapter(logger=self.logger, extra=None) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:18,代码来源:test_logging.py

示例2: __init__

# 需要导入模块: import logging [as 别名]
# 或者: from logging import LoggerAdapter [as 别名]
def __init__(self, client: ClipboardLayer, server: ClipboardLayer, log: LoggerAdapter, recorder: Recorder,
                 statCounter: StatCounter):
        """
        :param client: clipboard layer for the client side
        :param server: clipboard layer for the server side
        :param log: logger for this component
        :param recorder: recorder for clipboard data
        """
        self.statCounter = statCounter
        self.client = client
        self.server = server
        self.log = log
        self.recorder = recorder
        self.forwardNextDataResponse = True

        self.client.createObserver(
            onPDUReceived = self.onClientPDUReceived,
        )

        self.server.createObserver(
            onPDUReceived = self.onServerPDUReceived,
        ) 
开发者ID:GoSecure,项目名称:pyrdp,代码行数:24,代码来源:ClipboardMITM.py

示例3: __init__

# 需要导入模块: import logging [as 别名]
# 或者: from logging import LoggerAdapter [as 别名]
def __init__(self, viewer: QRemoteDesktop, text: QTextEdit, log: LoggerAdapter, fileSystem: FileSystem, layer: PlayerLayer, tabInstance: LiveTab):
        super().__init__(viewer, text)
        self.log = log
        self.fileSystem = fileSystem
        self.layer = layer
        self.drives: Dict[int, Drive] = {}
        self.downloadDirectories: Dict[str, Directory] = {}
        self.downloadFiles: Dict[str, BinaryIO] = {}
        self.downloadDialogs: Dict[str, FileDownloadDialog] = {}
        self.tabInstance = tabInstance

        # Clicking on an item and "downloading" is a job. Only one job at a time.
        # We need to process each job independently to keep the dialog reliable
        self.jobsQueue = set()
        self.directoryDownloadQueue = set()
        self.fileDownloadQueue = set()
        self.currentDownload = None

        self.handlers[PlayerPDUType.DIRECTORY_LISTING_RESPONSE] = self.handleDirectoryListingResponse
        self.handlers[PlayerPDUType.FILE_DOWNLOAD_RESPONSE] = self.handleDownloadResponse
        self.handlers[PlayerPDUType.FILE_DOWNLOAD_COMPLETE] = self.handleDownloadComplete
        self.handlers[PlayerPDUType.CLIENT_DATA] = self.onClientData
        self.handlers[PlayerPDUType.CONNECTION_CLOSE] = self.onConnectionClose 
开发者ID:GoSecure,项目名称:pyrdp,代码行数:25,代码来源:LiveEventHandler.py

示例4: __init__

# 需要导入模块: import logging [as 别名]
# 或者: from logging import LoggerAdapter [as 别名]
def __init__(self):
        self.todo_queue = queue.PriorityQueue()
        self.done_queues = {}
        self.done_tasks_time = dict()
        self.done_tasks_time_max = (60.0 * 20)
        self.broadcast_todo_queue = {}
        self.start_calc = {}
        self.out_tasks = {}
        self.proj_alive_time = {}
        self.proj_alive_time_max = (60 * 5)
        self.worker_alive_time = {}
        self.worker_alive_time_max = (60 * 30)
        self.pub_logger = logging.getLogger()
        self.pub_logger.setLevel(logging.WARN)
        if False:
            h = logging.handlers.RotatingFileHandler(filename='./server.log', mode='a', maxBytes=1000000, backupCount=10)
        else:
            h = logging.handlers.RotatingFileHandler(filename='./server.log', mode='a')
        f = logging.Formatter('%(asctime)s %(host)-16s %(job_id)-16s %(source_type)-8s %(levelname)-8s %(message)s')
        h.setFormatter(f)
        self.pub_logger.addHandler(h)
        self.logger = logging.LoggerAdapter(logging.getLogger(), {'host': os.environ.get('HOSTNAME', 'unknown'), 'job_id': os.environ.get('PBS_JOBID', 'N/A').split('.')[0], 'source_type': 'queue_server', })
        self.process = psutil.Process(os.getpid())
        _thread.start_new_thread(QueueServer.remove_dead_projects_daemon, (self,)) 
开发者ID:xulabs,项目名称:aitom,代码行数:26,代码来源:queue_server.py

示例5: log_config

# 需要导入模块: import logging [as 别名]
# 或者: from logging import LoggerAdapter [as 别名]
def log_config(event, loglevel=None, botolevel=None):
    if 'ResourceProperties' in event.keys():
        if 'loglevel' in event['ResourceProperties'] and not loglevel:
            loglevel = event['ResourceProperties']['loglevel']
        if 'botolevel' in event['ResourceProperties'] and not botolevel:
            loglevel = event['ResourceProperties']['botolevel']
    if not loglevel:
        loglevel = 'WARNING'
    if not botolevel:
        botolevel = 'ERROR'
    # Set log verbosity levels
    loglevel = getattr(logging, loglevel.upper(), 20)
    botolevel = getattr(logging, botolevel.upper(), 40)
    mainlogger = logging.getLogger()
    mainlogger.setLevel(loglevel)
    logging.getLogger('boto3').setLevel(botolevel)
    logging.getLogger('botocore').setLevel(botolevel)
    # Set log message format
    logfmt = '[%(requestid)s][%(asctime)s][%(levelname)s] %(message)s \n'
    mainlogger.handlers[0].setFormatter(logging.Formatter(logfmt))
    return logging.LoggerAdapter(mainlogger, {'requestid': event['RequestId']}) 
开发者ID:MattTunny,项目名称:AWS-Transit-Gateway-Demo-MultiAccount,代码行数:23,代码来源:crhelper.py

示例6: log_config

# 需要导入模块: import logging [as 别名]
# 或者: from logging import LoggerAdapter [as 别名]
def log_config(event, loglevel=None, botolevel=None):
    if 'ResourceProperties' in event.keys():
        if 'loglevel' in event['ResourceProperties'] and not loglevel:
            loglevel = event['ResourceProperties']['loglevel']
        if 'botolevel' in event['ResourceProperties'] and not botolevel:
            loglevel = event['ResourceProperties']['botolevel']
    if not loglevel:
        loglevel = 'warning'
    if not botolevel:
        botolevel = 'error'
    # Set log verbosity levels
    loglevel = getattr(logging, loglevel.upper(), 20)
    botolevel = getattr(logging, botolevel.upper(), 40)
    mainlogger = logging.getLogger()
    mainlogger.setLevel(loglevel)
    logging.getLogger('boto3').setLevel(botolevel)
    logging.getLogger('botocore').setLevel(botolevel)
    # Set log message format
    logfmt = '[%(requestid)s][%(asctime)s][%(levelname)s] %(message)s \n'
    mainlogger.handlers[0].setFormatter(logging.Formatter(logfmt))
    return logging.LoggerAdapter(mainlogger, {'requestid': event['RequestId']}) 
开发者ID:awslabs,项目名称:aws-cloudformation-templates,代码行数:23,代码来源:crhelper.py

示例7: get_event_log

# 需要导入模块: import logging [as 别名]
# 或者: from logging import LoggerAdapter [as 别名]
def get_event_log(pipeline_context: PipelineContext = None) \
  -> logging.Logger:
    """Get an instance of pipeline event logger.

    :Parameters:
    ----------
    pipe_context : PipelineContext

    :Returns:
    -------
    type
        Implementation of logging.Logger that handles pipeline events

    """
    pipeline_event_log = logging.getLogger(TIMELINE_EVENT_LOGGER_NAME)
    # wrap logger in an adapter that carries pipeline context
    # such as pipeline name and current pipe element.
    pipeline_event_log = logging.LoggerAdapter(
        pipeline_event_log,
        {PIPELINE_CONTEXT_KEY: pipeline_context})
    return pipeline_event_log 
开发者ID:ambianic,项目名称:ambianic-edge,代码行数:23,代码来源:timeline.py

示例8: __call__

# 需要导入模块: import logging [as 别名]
# 或者: from logging import LoggerAdapter [as 别名]
def __call__(  # lgtm[py/similar-function]
            self,
            *args: Any,
            type: str,
            event: bodies.RawEvent,
            body: bodies.Body,
            meta: bodies.Meta,
            spec: bodies.Spec,
            status: bodies.Status,
            uid: str,
            name: str,
            namespace: Optional[str],
            patch: patches.Patch,
            logger: Union[logging.Logger, logging.LoggerAdapter],
            **kwargs: Any,
    ) -> _SyncOrAsyncResult: ... 
开发者ID:zalando-incubator,项目名称:kopf,代码行数:18,代码来源:callbacks.py

示例9: run

# 需要导入模块: import logging [as 别名]
# 或者: from logging import LoggerAdapter [as 别名]
def run(self, logger=None, **kwargs):
        # type: (Union[logging.Logger, logging.LoggerAdapter], **Any) -> Iterator[Metric]
        if logger is None:
            logger = null_logger  # For convenience in unit tests and example scripts.

        logger.debug('document_query %s', self.name)

        for document, tags in self.source(**kwargs):
            logger.debug('%s %r', self.name, document)

            for spec in self.metrics:
                yield self._make_metric_from_spec(document, spec, tags=tags)

            for enumeration in self.enumerations:
                for metric in self._make_metrics_from_enumeration(document, enumeration, tags=tags):
                    yield metric

            for group in self.groups:
                for metric in self._make_metrics_from_group(document, group, tags=tags):
                    yield metric 
开发者ID:DataDog,项目名称:integrations-core,代码行数:22,代码来源:query.py

示例10: send_safe_iter

# 需要导入模块: import logging [as 别名]
# 或者: from logging import LoggerAdapter [as 别名]
def send_safe_iter(signal, logger, sender, **kwargs):
	utilities.assert_arg_type(signal, str, 1)
	utilities.assert_arg_type(logger, (logging.Logger, logging.LoggerAdapter), 2)

	signal = blinker.signal(signal)
	for receiver in signal.receivers_for(sender):
		try:
			result = receiver(sender, **kwargs)
		except Exception:
			calling_frame = inspect.stack()[1]
			logger.error("an error occurred while emitting signal '{0}' from {1}:{2}".format(signal, calling_frame[1], calling_frame[2]), exc_info=True)
		else:
			yield (receiver, result)
	return 
开发者ID:rsmusllp,项目名称:king-phisher,代码行数:16,代码来源:signals.py

示例11: upload_scratch_metadata

# 需要导入模块: import logging [as 别名]
# 或者: from logging import LoggerAdapter [as 别名]
def upload_scratch_metadata(self, koji_metadata, koji_upload_dir, koji_session):
        metadata_file = NamedTemporaryFile(prefix="metadata", suffix=".json", mode='wb')
        metadata_file.write(json.dumps(koji_metadata, indent=2).encode('utf-8'))
        metadata_file.flush()

        filename = "metadata.json"
        meta_output = Output(file=metadata_file, metadata={'filename': filename})

        try:
            self.upload_file(koji_session, meta_output, koji_upload_dir)
            path = os.path.join(koji_upload_dir, filename)
            log = logging.LoggerAdapter(self.log, {'arch': METADATA_TAG})
            log.info(path)
        finally:
            meta_output.file.close() 
开发者ID:containerbuildsystem,项目名称:atomic-reactor,代码行数:17,代码来源:exit_koji_import.py

示例12: __init__

# 需要导入模块: import logging [as 别名]
# 或者: from logging import LoggerAdapter [as 别名]
def __init__(self, build, cluster_info, logger):
        self.build = build
        self.cluster = cluster_info.cluster
        self.osbs = cluster_info.osbs
        self.platform = cluster_info.platform
        self.log = logging.LoggerAdapter(logger, {'arch': self.platform})

        self.monitor_exception = None 
开发者ID:containerbuildsystem,项目名称:atomic-reactor,代码行数:10,代码来源:build_orchestrate_build.py

示例13: config

# 需要导入模块: import logging [as 别名]
# 或者: from logging import LoggerAdapter [as 别名]
def config(self, loglevel='warning'):
        loglevel = logging.getLevelName(loglevel.upper())
        mainlogger = logging.getLogger()
        mainlogger.setLevel(loglevel)

        logfmt = '{"time_stamp": "%(asctime)s", "log_level": "%(levelname)s", "log_message": %(message)s}\n'
        if len(mainlogger.handlers) == 0:
            mainlogger.addHandler(logging.StreamHandler())
        mainlogger.handlers[0].setFormatter(logging.Formatter(logfmt))
        self.log = logging.LoggerAdapter(mainlogger, {}) 
开发者ID:awslabs,项目名称:efs-backup,代码行数:12,代码来源:logger.py

示例14: logger

# 需要导入模块: import logging [as 别名]
# 或者: from logging import LoggerAdapter [as 别名]
def logger(self):
        # Copy that to log
        extra = {"channelid" : self.channel.id, "userid": self.author.id}
        logger = logging.LoggerAdapter(self.bot.base_logger, extra)
        return logger 
开发者ID:DuckHunt-discord,项目名称:DHV3,代码行数:7,代码来源:context.py

示例15: logger

# 需要导入模块: import logging [as 别名]
# 或者: from logging import LoggerAdapter [as 别名]
def logger(self):
        if not self._logger:
            extra = {"channelid": self.channel.id, "userid": 0}
            self._logger = logging.LoggerAdapter(self.bot.base_logger, extra)

        return self._logger 
开发者ID:DuckHunt-discord,项目名称:DHV3,代码行数:8,代码来源:ducks.py


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