Skip to content

Commit aa6fa47

Browse files
authored
feat: Expose logger argument on Actor.call to control log redirection from started Actor run (#487)
### Description Added `logger` argument is used to either disable log redirection, use the default redirection logger or to pass custom logger that will process the redirected logs from started Actor run. ### Issues Related: apify/apify-client-js#632
1 parent 39d8df4 commit aa6fa47

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ keywords = [
3434
"scraping",
3535
]
3636
dependencies = [
37-
"apify-client>=1.9.2",
37+
"apify-client>=1.11.0",
3838
"apify-shared>=1.3.0",
3939
"crawlee~=0.6.0",
4040
"cryptography>=42.0.0",

src/apify/_actor.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,7 @@ async def call(
812812
timeout: timedelta | None | Literal['RemainingTime'] = None,
813813
webhooks: list[Webhook] | None = None,
814814
wait: timedelta | None = None,
815+
logger: logging.Logger | None | Literal['default'] = 'default',
815816
) -> ActorRun | None:
816817
"""Start an Actor on the Apify Platform and wait for it to finish before returning.
817818
@@ -834,6 +835,9 @@ async def call(
834835
a webhook set up for the Actor, you do not have to add it again here.
835836
wait: The maximum number of seconds the server waits for the run to finish. If not provided,
836837
waits indefinitely.
838+
logger: Logger used to redirect logs from the Actor run. Using "default" literal means that a predefined
839+
default logger will be used. Setting `None` will disable any log propagation. Passing custom logger
840+
will redirect logs to the provided logger.
837841
838842
Returns:
839843
Info about the started Actor run.
@@ -866,6 +870,7 @@ async def call(
866870
timeout_secs=int(actor_call_timeout.total_seconds()) if actor_call_timeout is not None else None,
867871
webhooks=serialized_webhooks,
868872
wait_secs=int(wait.total_seconds()) if wait is not None else None,
873+
logger=logger,
869874
)
870875

871876
return ActorRun.model_validate(api_result)

tests/unit/conftest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ def prepare_test_env(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> Callabl
3838
"""
3939

4040
def _prepare_test_env() -> None:
41-
delattr(apify._actor.Actor, '__wrapped__')
41+
if hasattr(apify._actor.Actor, '__wrapped__'):
42+
delattr(apify._actor.Actor, '__wrapped__')
4243
apify._actor._ActorType._is_any_instance_initialized = False
4344

4445
# Set the environment variable for the local storage directory to the temporary path.

uv.lock

Lines changed: 6 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)