Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/apify_client/_streamed_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from asyncio import Task
from datetime import UTC, datetime
from threading import Thread
from typing import TYPE_CHECKING, ClassVar, Self, cast
from typing import TYPE_CHECKING, ClassVar, Self

from apify_client._docs import docs_group

Expand Down Expand Up @@ -79,10 +79,10 @@ def _guess_log_level_from_message(message: str) -> int:
"""Guess the log level from the message."""
# Using only levels explicitly mentioned in the logging module
known_levels = ('CRITICAL', 'FATAL', 'ERROR', 'WARN', 'WARNING', 'INFO', 'DEBUG', 'NOTSET')
level_names_to_levels = logging.getLevelNamesMapping()
for level in known_levels:
if level in message:
# `getLevelName` returns an `int` when string is passed as input.
return cast('int', logging.getLevelName(level))
return level_names_to_levels[level]
# Unknown log level. Fall back to the default.
return logging.INFO

Expand Down
Loading
Loading