本文整理匯總了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']
)