當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。