Skip to content

Commit 06d8e6e

Browse files
Pijukatelvdusek
andauthored
Apply suggestions from code review
Co-authored-by: Vlada Dusek <[email protected]>
1 parent 26f0eda commit 06d8e6e

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

docs/03_concepts/10_logging.mdx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import LoggerUsageExample from '!!raw-loader!./code/10_logger_usage.py';
1010
import RedirectLog from '!!raw-loader!./code/10_redirect_log.py';
1111
import RedirectLogExistingRun from '!!raw-loader!./code/10_redirect_log_existing_run.py';
1212

13-
1413
The Apify SDK is logging useful information through the [`logging`](https://docs.python.org/3/library/logging.html) module from Python's standard library, into the logger with the name `apify`.
1514

1615
## Automatic configuration
@@ -86,10 +85,12 @@ Result:
8685

8786
<!-- markdownlint-enable no-inline-html -->
8887

89-
## Redirect logs from other actor runs
88+
## Redirect logs from other Actor runs
89+
9090
In some situations, one Actor is going to start one or more other Actors and wait for them to finish and produce some results. In such cases, you might want to redirect the logs and status messages of the started Actors runs back to the parent Actor run, so that you can see the progress of the started Actors' runs in the parent Actor's logs. This guide will show possibilities on how to do it.
9191

92-
### Redirecting logs from `Actor.call`
92+
### Redirecting logs from Actor.call
93+
9394
Typical use case for log redirection is to call another Actor using the [`Actor.call`](../../reference/class/Actor#call) method. This method has an optional `logger` argument, which is by default set to the `default` literal. This means that the logs of the called Actor will be automatically redirected to the parent Actor's logs with default formatting and filtering. If you set the `logger` argument to `None`, then no log redirection happens. The third option is to pass your own `Logger` instance with the possibility to define your own formatter, filter, and handler. Below you can see those three possible ways of log redirection when starting another Actor run through [`Actor.call`](../../reference/class/Actor#call).
9495

9596
<CodeBlock className="language-python">
@@ -103,6 +104,7 @@ The log redirection can be deep, meaning that if the other actor also starts ano
103104
![Console with redirected logs](/img/guides/redirected_logs_example.webp 'Example of console with redirected logs from recursively started actor.')
104105

105106
### Redirecting logs from already running Actor run
107+
106108
In some cases, you might want to connect to an already running Actor run and redirect its logs to your current Actor run. This can be done using the [ApifyClient](../../reference/class/Actor#apify_client) and getting the streamed log from a specific Actor run. You can then use it as a context manager, and the log redirection will be active in the context, or you can control the log redirection manually by explicitly calling `start` and `stop` methods.
107109

108110
You can further decide whether you want to redirect just new logs of the ongoing Actor run, or if you also want to redirect historical logs from that Actor's run, so all logs it has produced since it was started. Both options are shown in the example code below.

0 commit comments

Comments
 (0)