本文整理汇总了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
示例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)
示例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
)
示例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")
示例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"
示例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"
示例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)
示例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']
)