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


Python logging.logger方法代码示例

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


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

示例1: _get_panoptes_logger

# 需要导入模块: import logging [as 别名]
# 或者: from logging import logger [as 别名]
def _get_panoptes_logger(self):
        """
        Returns the logger to be used by the context

        The method attempts to guess the name of the calling module based on introspection of the stack

        Returns:
            logger(logger): A Python logger subsystem logger

        Raises:
            PanoptesContextError: This exception is raised is any errors happen trying to instantiate the logger
        """
        self.__logger.info(u'Attempting to get logger')
        try:
            module = get_calling_module_name()
            logger = self.__rootLogger.getChild(module)
            self.__logger.info(u'Got logger for module %s' % module)
            return logger
        except Exception as e:
            raise PanoptesContextError(u'Could not get logger: %s' % str(e)) 
开发者ID:yahoo,项目名称:panoptes,代码行数:22,代码来源:context.py

示例2: attach

# 需要导入模块: import logging [as 别名]
# 或者: from logging import logger [as 别名]
def attach(self, engine: Engine):
        """
        Register a set of Ignite Event-Handlers to a specified Ignite engine.

        Args:
            engine: Ignite Engine, it can be a trainer, validator or evaluator.

        """
        if self._name is None:
            self.logger = engine.logger
        if not engine.has_event_handler(self.iteration_completed, Events.ITERATION_COMPLETED):
            engine.add_event_handler(Events.ITERATION_COMPLETED, self.iteration_completed)
        if not engine.has_event_handler(self.epoch_completed, Events.EPOCH_COMPLETED):
            engine.add_event_handler(Events.EPOCH_COMPLETED, self.epoch_completed)
        if not engine.has_event_handler(self.exception_raised, Events.EXCEPTION_RAISED):
            engine.add_event_handler(Events.EXCEPTION_RAISED, self.exception_raised) 
开发者ID:Project-MONAI,项目名称:MONAI,代码行数:18,代码来源:stats_handler.py

示例3: wait_for_workers

# 需要导入模块: import logging [as 别名]
# 或者: from logging import logger [as 别名]
def wait_for_workers(self, min_n_workers=1):
		"""
		helper function to hold execution until some workers are active

		Parameters
		----------
		min_n_workers: int
			minimum number of workers present before the run starts		
		"""
	
		self.logger.debug('wait_for_workers trying to get the condition')
		with self.thread_cond:
			while (self.dispatcher.number_of_workers() < min_n_workers):
				self.logger.debug('HBMASTER: only %i worker(s) available, waiting for at least %i.'%(self.dispatcher.number_of_workers(), min_n_workers))
				self.thread_cond.wait(1)
				self.dispatcher.trigger_discover_worker()
				
		self.logger.debug('Enough workers to start this run!') 
开发者ID:automl,项目名称:HpBandSter,代码行数:20,代码来源:master.py

示例4: job_callback

# 需要导入模块: import logging [as 别名]
# 或者: from logging import logger [as 别名]
def job_callback(self, job):
		"""
		method to be called when a job has finished

		this will do some book keeping and call the user defined
		new_result_callback if one was specified
		"""
		self.logger.debug('job_callback for %s started'%str(job.id))
		with self.thread_cond:
			self.logger.debug('job_callback for %s got condition'%str(job.id))
			self.num_running_jobs -= 1

			if not self.result_logger is None:
				self.result_logger(job)
			self.iterations[job.id[0]].register_result(job)
			self.config_generator.new_result(job)

			if self.num_running_jobs <= self.job_queue_sizes[0]:
				self.logger.debug("HBMASTER: Trying to run another job!")
				self.thread_cond.notify()

		self.logger.debug('job_callback for %s finished'%str(job.id)) 
开发者ID:automl,项目名称:HpBandSter,代码行数:24,代码来源:master.py

示例5: __init__

# 需要导入模块: import logging [as 别名]
# 或者: from logging import logger [as 别名]
def __init__(self, logger=None):
		"""
		Parameters
		----------

		directory: string
			where the results are logged
		logger: hpbandster.utils.result_logger_v??
			the logger to store the data, defaults to v1
		overwrite: bool
			whether or not existing data will be overwritten
		logger: logging.logger
			for some debug output

		"""

		if logger is None:
			self.logger=logging.getLogger('hpbandster')
		else:
			self.logger=logger 
开发者ID:automl,项目名称:HpBandSter,代码行数:22,代码来源:base_config_generator.py

示例6: new_result

# 需要导入模块: import logging [as 别名]
# 或者: from logging import logger [as 别名]
def new_result(self, job, update_model=True):
		"""
		registers finished runs

		Every time a run has finished, this function should be called
		to register it with the result logger. If overwritten, make
		sure to call this method from the base class to ensure proper
		logging.


		Parameters
		----------
		job: instance of hpbandster.distributed.dispatcher.Job
			contains all necessary information about the job
		update_model: boolean
			determines whether a model inside the config_generator should be updated
		"""
		if not job.exception is None:
			self.logger.warning("job {} failed with exception\n{}".format(job.id, job.exception)) 
开发者ID:automl,项目名称:HpBandSter,代码行数:21,代码来源:base_config_generator.py

示例7: _timer

# 需要导入模块: import logging [as 别名]
# 或者: from logging import logger [as 别名]
def _timer(name, _logger=None, level="info"):
    """
    Output execution time of a function to the given logger level

    Parameters
    ----------
    name : str
        How to name the timer (will be in the logs)
    logger : logging.logger
        The optional logger where to write
    level : str
        On which level to log the performance measurement
    """
    start = tic()
    _logger = _logger or logger
    _logger.info("Starting %s", name)
    yield
    stop = tic()
    delta = datetime.timedelta(seconds=stop - start)
    _logger_level = getattr(_logger, level)
    _logger_level("Finished %s in %s", name, delta)  # nicer formatting for time. 
开发者ID:dask,项目名称:dask-ml,代码行数:23,代码来源:utils.py

示例8: _timed

# 需要导入模块: import logging [as 别名]
# 或者: from logging import logger [as 别名]
def _timed(_logger=None, level="info"):
    """
    Output execution time of a function to the given logger level

    level : str
        On which level to log the performance measurement
    Returns
    -------
    fun_wrapper : Callable
    """

    def fun_wrapper(f):
        @functools.wraps(f)
        def wraps(*args, **kwargs):
            with _timer(f.__name__, _logger=logger, level=level):
                results = f(*args, **kwargs)
            return results

        return wraps

    return fun_wrapper 
开发者ID:dask,项目名称:dask-ml,代码行数:23,代码来源:utils.py

示例9: exception_log

# 需要导入模块: import logging [as 别名]
# 或者: from logging import logger [as 别名]
def exception_log(logger, head_msg, ex, level=logging.ERROR):
    """Helper to dump exception in the logger

    Parameters
    ----------
    logger: logging.logger
        the logger
    head_msg: string
        a human friendly message to prefix the exception stacktrace
    ex: Exception
        the exception
    level: type
        The wanted level (ERROR by default)

    """
    logger.log(level, "%s:" % head_msg)
    logger.log(level, "<br />".join(traceback.format_exception(etype=type(ex), value=ex, tb=ex.__traceback__)))


###############################################################################
# Callbacks
############################################################################### 
开发者ID:asuni,项目名称:wavelet_prosody_toolkit,代码行数:24,代码来源:wavelet_gui.py

示例10: _configure_ulog_bridge

# 需要导入模块: import logging [as 别名]
# 或者: from logging import logger [as 别名]
def _configure_ulog_bridge():
    # Get the ulog entries of this process into a Python logging.logger
    # This "ulog" logger has no log handler by default and should only
    # be activated for debugging
    ulog_logger = logging.getLogger("ulog")
    ulog.enable_bridge(ulog_logger, forward=False) 
开发者ID:Parrot-Developers,项目名称:olympe,代码行数:8,代码来源:__init__.py

示例11: logger

# 需要导入模块: import logging [as 别名]
# 或者: from logging import logger [as 别名]
def logger(self):
        """
        A module-aware logger which will try and guess the right name for the calling module

        Returns:
            logging.logger

        """
        return self.__logger 
开发者ID:yahoo,项目名称:panoptes,代码行数:11,代码来源:context.py

示例12: __init__

# 需要导入模块: import logging [as 别名]
# 或者: from logging import logger [as 别名]
def __init__(
        self,
        output_dir: str = "./",
        filename: str = "predictions.csv",
        overwrite: bool = True,
        batch_transform: Callable = lambda x: x,
        output_transform: Callable = lambda x: x,
        name: Optional[str] = None,
    ):
        """
        Args:
            output_dir: output CSV file directory.
            filename: name of the saved CSV file name.
            overwrite: whether to overwriting existing CSV file content. If we are not overwriting,
                then we check if the results have been previously saved, and load them to the prediction_dict.
            batch_transform: a callable that is used to transform the
                ignite.engine.batch into expected format to extract the meta_data dictionary.
            output_transform: a callable that is used to transform the
                ignite.engine.output into the form expected model prediction data.
                The first dimension of this transform's output will be treated as the
                batch dimension. Each item in the batch will be saved individually.
            name: identifier of logging.logger to use, defaulting to `engine.logger`.

        """
        self.saver = CSVSaver(output_dir, filename, overwrite)
        self.batch_transform = batch_transform
        self.output_transform = output_transform

        self.logger = None if name is None else logging.getLogger(name)
        self._name = name 
开发者ID:Project-MONAI,项目名称:MONAI,代码行数:32,代码来源:classification_saver.py

示例13: attach

# 需要导入模块: import logging [as 别名]
# 或者: from logging import logger [as 别名]
def attach(self, engine: Engine):
        if self._name is None:
            self.logger = engine.logger
        if not engine.has_event_handler(self, Events.ITERATION_COMPLETED):
            engine.add_event_handler(Events.ITERATION_COMPLETED, self)
        if not engine.has_event_handler(self.saver.finalize, Events.COMPLETED):
            engine.add_event_handler(Events.COMPLETED, lambda engine: self.saver.finalize()) 
开发者ID:Project-MONAI,项目名称:MONAI,代码行数:9,代码来源:classification_saver.py

示例14: exception_raised

# 需要导入模块: import logging [as 别名]
# 或者: from logging import logger [as 别名]
def exception_raised(self, engine: Engine, e):
        """
        Handler for train or validation/evaluation exception raised Event.
        Print the exception information and traceback.

        Args:
            engine: Ignite Engine, it can be a trainer, validator or evaluator.
            e (Exception): the exception caught in Ignite during engine.run().

        """
        self.logger.exception(f"Exception: {e}")
        # import traceback
        # traceback.print_exc() 
开发者ID:Project-MONAI,项目名称:MONAI,代码行数:15,代码来源:stats_handler.py

示例15: attach

# 需要导入模块: import logging [as 别名]
# 或者: from logging import logger [as 别名]
def attach(self, engine: Engine):
        if self._name is None:
            self.logger = engine.logger
        if not engine.has_event_handler(self, Events.ITERATION_COMPLETED):
            engine.add_event_handler(Events.ITERATION_COMPLETED, self) 
开发者ID:Project-MONAI,项目名称:MONAI,代码行数:7,代码来源:segmentation_saver.py


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