> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.conductorquantum.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.conductorquantum.com/_mcp/server.

# stanza.jupyter.logs

Log streaming for Jupyter notebooks and servers.

## Module Contents

### Functions

| Name | Description |
|------|-------------|
| [`_wait_for_log`](#stanzajupyterlogs_wait_for_log) | Wait for log file to exist or timeout. |
| [`_print_tail`](#stanzajupyterlogs_print_tail) | Print last N lines from log file with proper terminal alignment. |
| [`_stream_log`](#stanzajupyterlogs_stream_log) | Read and print new log lines with proper terminal alignment. |
| [`follow`](#stanzajupyterlogsfollow) | Stream log file until Ctrl+C. |
| [`attach`](#stanzajupyterlogsattach) | Stream log file with active kernel control. |

### API

```python
stanza.jupyter.logs._wait_for_log(
    log_file: pathlib.Path, timeout: float = 30.0
) -> None
```

Wait for log file to exist or timeout.

Polls for the log file's existence, displaying a waiting message to stderr.
Exits with status 1 if the file doesn't appear within the timeout period.

**Parameters:**

<ParamField path="log_file" type="pathlib.Path">
  Path to the log file to wait for
</ParamField>

<ParamField path="timeout" type="float" default="30.0">
  Maximum seconds to wait before exiting
</ParamField>


```python
stanza.jupyter.logs._print_tail(
    log_file: pathlib.Path, lines: int
) -> None
```

Print last N lines from log file with proper terminal alignment.

**Parameters:**

<ParamField path="log_file" type="pathlib.Path">
  Path to the log file to read
</ParamField>

<ParamField path="lines" type="int">
  Number of lines to print from the end of the file
</ParamField>


```python
stanza.jupyter.logs._stream_log(
    f: object,
    poll_interval: float,
    log_file: pathlib.Path
) -> None
```

Read and print new log lines with proper terminal alignment.

Strips carriage return artifacts from progress bars and formats output
for proper terminal display. Exits if the log file is deleted.

**Parameters:**

<ParamField path="f" type="object">
  Open file handle positioned at the current read position
</ParamField>

<ParamField path="poll_interval" type="float">
  Seconds to sleep when no new data is available
</ParamField>

<ParamField path="log_file" type="pathlib.Path">
  Path to the log file (for existence checking)
</ParamField>


```python
stanza.jupyter.logs.follow(
    log_file: pathlib.Path,
    lines: int = 10,
    poll_interval: float = 0.1
) -> None
```

Stream log file until Ctrl+C.

Displays the last N lines of the log file, then continuously streams new
lines as they are written. Exits gracefully on Ctrl+C.

**Parameters:**

<ParamField path="log_file" type="pathlib.Path">
  Path to the log file to follow
</ParamField>

<ParamField path="lines" type="int" default="10">
  Number of initial lines to display from the end of the file
</ParamField>

<ParamField path="poll_interval" type="float" default="0.1">
  Seconds to wait between checks for new content
</ParamField>


```python
stanza.jupyter.logs.attach(
    log_file: pathlib.Path,
    kill_callback: collections.abc.Callable[[], None],
    lines: int = 10,
    poll_interval: float = 0.1
) -> None
```

Stream log file with active kernel control.

Displays the last N lines of the log file, then continuously streams new
lines. Ctrl+C kills the kernel via the callback. ESC exits without killing
(press twice for safety).

**Parameters:**

<ParamField path="log_file" type="pathlib.Path">
  Path to the log file to follow
</ParamField>

<ParamField path="kill_callback" type="collections.abc.Callable[[], None]">
  Function to call when Ctrl+C is pressed
</ParamField>

<ParamField path="lines" type="int" default="10">
  Number of initial lines to display from the end of the file
</ParamField>

<ParamField path="poll_interval" type="float" default="0.1">
  Seconds to wait between checks for new content
</ParamField>