Skip to content

Commit f25ccd4

Browse files
committed
Do not use root logger
1 parent 9c1c6e3 commit f25ccd4

6 files changed

Lines changed: 10 additions & 10 deletions

File tree

doctr/file_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def requires_package(name: str, extra_message: str | None = None) -> None: # pr
2222
"""
2323
try:
2424
_pkg_version = importlib.metadata.version(name)
25-
logging.info(f"{name} version {_pkg_version} available.")
25+
logging.getLogger(__name__).info(f"{name} version {_pkg_version} available.")
2626
except importlib.metadata.PackageNotFoundError:
2727
raise ImportError(
2828
f"\n\n{extra_message if extra_message is not None else ''} "

doctr/models/factory/hub.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def login_to_hub() -> None: # pragma: no cover
3737
"""Login to huggingface hub"""
3838
access_token = get_token()
3939
if access_token is not None:
40-
logging.info("Huggingface Hub token found and valid")
40+
logging.getLogger(__name__).info("Huggingface Hub token found and valid")
4141
login(token=access_token)
4242
else:
4343
login()

doctr/models/utils/pytorch.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def load_pretrained_params(
5858
**kwargs: additional arguments to be passed to `doctr.utils.data.download_from_url`
5959
"""
6060
if path_or_url is None:
61-
logging.warning("No model URL or Path provided, using default initialization.")
61+
logging.getLogger(__name__).warning("No model URL or Path provided, using default initialization.")
6262
return
6363

6464
archive_path = (
@@ -197,7 +197,7 @@ def export_model_to_onnx(
197197
verbose=False,
198198
**kwargs,
199199
)
200-
logging.info(f"Model exported to {model_name}.onnx")
200+
logging.getLogger(__name__).info(f"Model exported to {model_name}.onnx")
201201
return f"{model_name}.onnx"
202202

203203

@@ -451,7 +451,7 @@ def _constrain_logits(
451451

452452
if verbose: # pragma: no cover
453453
kept = sum(char in allowed for char in vocab)
454-
logging.info(
454+
logging.getLogger(__name__).info(
455455
f"add_whitelist: {type(reco_model).__name__} - kept {kept}/{vocab_size} vocabulary "
456456
f"characters, forbade {vocab_size - kept}"
457457
+ (f", reassigned {reassigned} to a nearest allowed character." if strategy == "nearest" else ".")

doctr/utils/data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def download_from_url(
8484
file_path = folder_path.joinpath(file_name)
8585
# Check file existence
8686
if file_path.is_file() and (hash_prefix is None or _check_integrity(file_path, hash_prefix)):
87-
logging.info(f"Using downloaded & verified file: {file_path}")
87+
logging.getLogger(__name__).info(f"Using downloaded & verified file: {file_path}")
8888
return file_path
8989

9090
try:
@@ -98,7 +98,7 @@ def download_from_url(
9898
error_message += (
9999
". You can change default cache directory using 'DOCTR_CACHE_DIR' environment variable if needed."
100100
)
101-
logging.error(error_message)
101+
logging.getLogger(__name__).error(error_message)
102102
raise
103103
# Download the file
104104
try:

doctr/utils/fonts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def get_font(font_family: str | None = None, font_size: int = 13) -> ImageFont.F
2727
font = ImageFont.truetype("FreeMono.ttf" if platform.system() == "Linux" else "Arial.ttf", font_size)
2828
except OSError: # pragma: no cover
2929
font = ImageFont.load_default() # type: ignore[assignment]
30-
logging.warning(
30+
logging.getLogger(__name__).warning(
3131
"unable to load recommended font family. Loading default PIL font,"
3232
"font size issues may be expected."
3333
"To prevent this, it is recommended to specify the value of 'font_family'."

doctr/utils/reconstitution.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
def _warn_rotation(entry: dict[str, Any]) -> None: # pragma: no cover
2222
global ROTATION_WARNING
2323
if not ROTATION_WARNING and len(entry["geometry"]) == 4:
24-
logging.warning("Polygons with larger rotations will lead to inaccurate rendering")
24+
logging.getLogger(__name__).warning("Polygons with larger rotations will lead to inaccurate rendering")
2525
ROTATION_WARNING = True
2626

2727

@@ -84,7 +84,7 @@ def _synthesize(
8484
d.text((xmin, ymin), anyascii(word_text), font=font, fill=(0, 0, 0), anchor="lt")
8585
# Catch generic exceptions to avoid crashing the whole rendering
8686
except Exception: # pragma: no cover
87-
logging.warning(f"Could not render word: {word_text}")
87+
logging.getLogger(__name__).warning(f"Could not render word: {word_text}")
8888

8989
if draw_proba:
9090
confidence = (

0 commit comments

Comments
 (0)