當前位置: 首頁>>代碼示例>>Python>>正文


Python logger.trace方法代碼示例

本文整理匯總了Python中loguru.logger.trace方法的典型用法代碼示例。如果您正苦於以下問題:Python logger.trace方法的具體用法?Python logger.trace怎麽用?Python logger.trace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在loguru.logger的用法示例。


在下文中一共展示了logger.trace方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _load_file_of_url

# 需要導入模塊: from loguru import logger [as 別名]
# 或者: from loguru.logger import trace [as 別名]
def _load_file_of_url(path: str) -> str:
    """Detects if path is local or URL, loads file content

    Args:
        path (str): [description]

    Returns:
        str: [description]
    """
    if isfile(path):
        logger.trace(f"reading from file [{path}]..", end="")
        with open(path, "r") as f:
            content = f.read()
        logger.trace("ok")
    elif urlparse(path).scheme in {"ftp", "http", "https"}:
        logger.trace(f"trying to download [{path}]..", end="")
        req = urlopen(path)
        if req.getcode() != 200:
            raise ValueError(
                f"Invalid input URL request returned {req.getcode()}"
            )
        logger.trace("ok")
        content = req.read().decode("utf-8")
    else:
        raise ValueError(f"Unrecognized input path {path}")

    return content 
開發者ID:ljvmiranda921,項目名稱:seagull,代碼行數:29,代碼來源:wiki.py

示例2: gather_arrays

# 需要導入模塊: from loguru import logger [as 別名]
# 或者: from loguru.logger import trace [as 別名]
def gather_arrays(self, arrays):
        """Gather given variables from parent state object"""
        from .distributed import gather
        for arr in arrays:
            if not hasattr(self._vs, arr):
                continue
            self._gathered.add(arr)
            logger.trace(' Gathering {}', arr)
            gathered_arr = gather(
                self._vs,
                getattr(self._vs, arr),
                self._vs.variables[arr].dims
            )
            setattr(self, arr, gathered_arr) 
開發者ID:team-ocean,項目名稱:veros,代碼行數:16,代碼來源:state_dist.py

示例3: scatter_arrays

# 需要導入模塊: from loguru import logger [as 別名]
# 或者: from loguru.logger import trace [as 別名]
def scatter_arrays(self):
        """Sync all changes with parent state object"""
        from .distributed import scatter
        for arr in sorted(self._gathered):
            if not hasattr(self._vs, arr):
                continue
            logger.trace(' Scattering {}', arr)
            getattr(self._vs, arr)[...] = scatter(
                self._vs,
                getattr(self, arr),
                self._vs.variables[arr].dims
            ) 
開發者ID:team-ocean,項目名稱:veros,代碼行數:14,代碼來源:state_dist.py

示例4: _load_spatialite

# 需要導入模塊: from loguru import logger [as 別名]
# 或者: from loguru.logger import trace [as 別名]
def _load_spatialite(self, conn):
        """Load mod_spatialite or libspatialite"""

        try:
            conn.load_extension("mod_spatialite")
            logger.trace("Using mod_spatialite")
        except sqlite3.OperationalError:
            conn.load_extension("libspatialite")
            logger.trace("Using libspatialite") 
開發者ID:thinkingmachines,項目名稱:geomancer,代碼行數:11,代碼來源:sqlite.py

示例5: test_propagate

# 需要導入模塊: from loguru import logger [as 別名]
# 或者: from loguru.logger import trace [as 別名]
def test_propagate(make_logging_logger, capsys):
    logging_logger = make_logging_logger("tests", StreamHandler(sys.stderr))

    logging_logger.debug("1")
    logger.debug("2")

    logger.add(PropagateHandler(), format="{message}")

    logger.debug("3")
    logger.trace("4")

    out, err = capsys.readouterr()
    assert out == ""
    assert err == "1\n3\n" 
開發者ID:Delgan,項目名稱:loguru,代碼行數:16,代碼來源:test_propagation.py

示例6: test_logging_within_lazy_function

# 需要導入模塊: from loguru import logger [as 別名]
# 或者: from loguru.logger import trace [as 別名]
def test_logging_within_lazy_function(writer):
    logger.add(writer, level=20, format="{message}")

    def laziness():
        logger.trace("Nope")
        logger.warning("Yes Warn")

    logger.opt(lazy=True).trace("No", laziness)

    assert writer.read() == ""

    logger.opt(lazy=True).info("Yes", laziness)

    assert writer.read() == "Yes Warn\nYes\n" 
開發者ID:Delgan,項目名稱:loguru,代碼行數:16,代碼來源:test_opt.py

示例7: test_updating_min_level

# 需要導入模塊: from loguru import logger [as 別名]
# 或者: from loguru.logger import trace [as 別名]
def test_updating_min_level(writer):
    logger.debug("Early exit -> no {error}", nope=None)

    a = logger.add(writer, level="DEBUG")

    with pytest.raises(KeyError):
        logger.debug("An {error} will occur!", nope=None)

    logger.trace("Early exit -> no {error}", nope=None)

    logger.add(writer, level="INFO")
    logger.remove(a)

    logger.debug("Early exit -> no {error}", nope=None) 
開發者ID:Delgan,項目名稱:loguru,代碼行數:16,代碼來源:test_levels.py

示例8: download_songs

# 需要導入模塊: from loguru import logger [as 別名]
# 或者: from loguru.logger import trace [as 別名]
def download_songs(mm, songs, template=None):
	if not songs:
		logger.log('NORMAL', "No songs to download")
	else:
		logger.log('NORMAL', "Downloading songs from Google Music")

		if not template:
			template = Path.cwd()

		songnum = 0
		total = len(songs)
		pad = len(str(total))

		for song in songs:
			songnum += 1

			logger.trace(
				"Downloading -- {} - {} - {} ({})",
				song.get('title', "<title>"),
				song.get('artist', "<artist>"),
				song.get('album', "<album>"),
				song['id']
			)

			try:
				audio, _ = mm.download(song)
			except Exception as e:  # TODO: More specific exception.
				logger.log(
					'ACTION_FAILURE',
					"({:>{}}/{}) Failed -- {} | {}",
					songnum,
					pad,
					total,
					song,
					e
				)
			else:
				tags = audio_metadata.loads(audio).tags
				filepath = gm_utils.template_to_filepath(template, tags).with_suffix('.mp3')
				if filepath.is_file():
					filepath.unlink()

				filepath.parent.mkdir(parents=True, exist_ok=True)
				filepath.touch()
				filepath.write_bytes(audio)

				logger.log(
					'ACTION_SUCCESS',
					"({:>{}}/{}) Downloaded -- {} ({})",
					songnum,
					pad,
					total,
					filepath,
					song['id']
				) 
開發者ID:thebigmunch,項目名稱:google-music-scripts,代碼行數:57,代碼來源:core.py


注:本文中的loguru.logger.trace方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。