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
2 changes: 1 addition & 1 deletion .github/workflows/bandit-sarif.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
steps:
- # Checkout repository code
name: Checkout
uses: actions/checkout@v6
uses: actions/checkout@v7

- # Setup Python for Bandit scanning
name: Set up Python
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
steps:
- # Checkout repository code
name: Checkout
uses: actions/checkout@v6
uses: actions/checkout@v7

- # Setup Python version and pip cache
name: Set up Python
Expand Down Expand Up @@ -191,7 +191,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v6
uses: actions/checkout@v7

- name: Set up Python
uses: actions/setup-python@v6
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v7

# Add any setup steps before running the `github/codeql-action/init` action.
# This includes steps like installing compilers or runtimes (`actions/setup-node`
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
steps:
- # Checkout repository code
name: Checkout
uses: actions/checkout@v6
uses: actions/checkout@v7

- # Setup Python for MkDocs build
name: Set up Python
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/i18n.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
steps:
- # Checkout repository code
name: Checkout
uses: actions/checkout@v6
uses: actions/checkout@v7

- # Setup Python 3.12 for i18n tools
name: Set up Python
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
steps:
- # Checkout repository code
name: Checkout
uses: actions/checkout@v6
uses: actions/checkout@v7

- # Setup Python and pip cache
name: Set up Python
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v6
uses: actions/checkout@v7

- name: Set up Python
uses: actions/setup-python@v6
Expand Down Expand Up @@ -146,7 +146,7 @@ jobs:
echo "title=$title" >> "$GITHUB_OUTPUT"

- name: Create GitHub Release
uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda # v3
uses: softprops/action-gh-release@718ea10b132b3b2eba29c1007bb80653f286566b # v3
with:
name: ${{ steps.release_title.outputs.title }}
draft: false
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/vibe-coded.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
# rejected by the protected branch. Falls back to GITHUB_TOKEN if the
# secret is unset (push will then be skipped, not fail the run).
name: Checkout
uses: actions/checkout@v6
uses: actions/checkout@v7
with:
fetch-depth: 0
token: ${{ secrets.VIBE_BADGE_TOKEN || secrets.GITHUB_TOKEN }}
Expand Down
45 changes: 44 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,46 @@
# Changelog

See the releases on GitHub for detailed changelogs once you publish this plugin: [https://github.com/Ajimaru/OctoPrint-LogMonitor/releases](https://github.com/Ajimaru/OctoPrint-LogMonitor/releases)
All notable changes to this project are documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
For the detailed history of published versions, see the
[GitHub releases](https://github.com/Ajimaru/OctoPrint-LogMonitor/releases).

## [Unreleased]

### Added

- Shared `log_parser` module: streaming and searching now classify log
lines identically (search understands serial and compact formats too).
- Copy-truncate log rotation detection: a truncated file no longer stalls
the live stream.
- Documentation: configuration reference, REST API reference, and
troubleshooting guide.

### Changed

- Search now streams through log files line by line instead of loading
them fully into memory; the initial-lines read also uses backward block
reads. Memory use no longer scales with file size.
- Hyphenated logger names (e.g. `octoprint.plugins.my-plugin`) parse
correctly.
- `max_alert_history` is now consistently capped at 500 in settings, UI,
and runtime.

### Fixed

- Batched line delivery now starts reliably for auto-started and
multi-file streams, and stopping the single-file stream no longer stalls
active multi-file streams.
- The line buffer is hard-capped so memory stays bounded even if flushing
stalls; the search rate limiter prunes idle clients automatically.
- `POST /stream/multi/stop` with `stop_all` reports the actual number of
stopped streams.

## [0.2.3] - 2026-06

- Version 0.2.3: improved log path validation and error handling.

See [GitHub releases](https://github.com/Ajimaru/OctoPrint-LogMonitor/releases)
for earlier versions.
28 changes: 27 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@
- 🔀 **Multi-Stream API** - Backend endpoints for parallel streaming of multiple logs
- 🛡️ **Secure** - Path traversal protection, input validation, and rate limiting

## Documentation

Full documentation lives at **[ajimaru.github.io/OctoPrint-LogMonitor](https://ajimaru.github.io/OctoPrint-LogMonitor/)**:

- [Configuration reference](https://ajimaru.github.io/OctoPrint-LogMonitor/configuration/) - every setting, default, and limit
- [REST API reference](https://ajimaru.github.io/OctoPrint-LogMonitor/rest-api/) - all plugin endpoints and WebSocket push messages
- [Troubleshooting](https://ajimaru.github.io/OctoPrint-LogMonitor/troubleshooting/) - common problems and fixes

## Installation

### Via Plugin Manager (Recommended)
Expand Down Expand Up @@ -70,7 +78,7 @@ The `releases/latest` URL always points to the newest stable release.

## Configuration

Access plugin settings via OctoPrint Settings → Plugins → Log Monitor
Access plugin settings via OctoPrint Settings → Plugins → Log Monitor. The most important options are listed below; see the [configuration reference](https://ajimaru.github.io/OctoPrint-LogMonitor/configuration/) for the complete list with ranges and built-in limits.

### Display Settings

Expand Down Expand Up @@ -131,6 +139,24 @@ When a log entry matches configured trigger severities (default: WARNING/ERROR/C
- The Sidebar widget updates (if enabled)
- Click the badge/widget to open the Log Monitor tab and reset alerts

## Development

```bash
git clone https://github.com/Ajimaru/OctoPrint-LogMonitor.git
cd OctoPrint-LogMonitor
python -m venv .venv && source .venv/bin/activate
python -m pip install -e .[develop]

# Run the test suite
python -m pytest

# Lint / format
python -m flake8 octoprint_logmonitor tests
python -m black octoprint_logmonitor tests
```

The plugin API used by the frontend is documented in the [REST API reference](https://ajimaru.github.io/OctoPrint-LogMonitor/rest-api/).

## Contributing

Contributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for detailed guidelines and instructions.
Expand Down
4 changes: 4 additions & 0 deletions docs/api/python.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

This page is generated from Python docstrings.

## `log_parser`

::: octoprint_logmonitor.log_parser

## `log_searcher`

::: octoprint_logmonitor.log_searcher
Expand Down
3 changes: 2 additions & 1 deletion docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
Use the GitHub releases page for the detailed history of published versions.

- [Releases](https://github.com/Ajimaru/OctoPrint-LogMonitor/releases)
- [`CHANGELOG.md`](https://github.com/Ajimaru/OctoPrint-LogMonitor/blob/main/CHANGELOG.md) — unreleased changes

## Current release line

- 0.1.x: initial public plugin line with log streaming, search, alerts, and security controls
- 0.2.x: log streaming, search, alerts, multi-file streaming API, and security controls
59 changes: 59 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Configuration Reference

All settings live under **OctoPrint Settings → Plugins → Log Monitor**.
Values outside the allowed range are clamped automatically when saved.

## Display

| Setting | Default | Description |
| -------------- | ------- | ------------------------------------------------ |
| `show_navbar` | `true` | Show the alert badge in the OctoPrint navbar. |
| `show_sidebar` | `true` | Show the status widget in the OctoPrint sidebar. |

## Streaming

| Setting | Default | Range | Description |
| ------------------------ | --------------- | --------- | --------------------------------------------------------------------------- |
| `default_log_file` | `octoprint.log` | — | Log file preselected in the tab and used for auto-start. |
| `stream_poll_interval_s` | `5` | 1–60 s | How often the tailer polls for new lines and batches are flushed to the UI. |
| `max_stream_lines` | `500` | 100–10000 | Maximum lines kept in the live view buffer. |
| `auto_scroll` | `true` | — | Scroll to the newest line automatically. |
| `auto_start_streaming` | `false` | — | Start streaming `default_log_file` when OctoPrint starts. |

## Search

| Setting | Default | Range | Description |
| ---------------------- | ------- | ------ | -------------------------------------------------- |
| `search_page_size` | `50` | 10–500 | Results per page. |
| `regex_search_enabled` | `false` | — | Allow regular-expression queries in the search UI. |

## Alerts

| Setting | Default | Range | Description |
| ----------------------- | -------------------------------- | ------ | -------------------------------------------------------------------------- |
| `alerts_enabled` | `true` | — | Master switch for severity alerting. |
| `severity_triggers` | `["WARNING","ERROR","CRITICAL"]` | — | Levels that raise an alert. |
| `alerts_monitor_mode` | `selected` | — | `all` monitors every `.log` file; `selected` only `alerts_monitored_logs`. |
| `alerts_monitored_logs` | `["octoprint.log"]` | — | Files watched by the background alert monitor (mode `selected`). |
| `alert_history_enabled` | `true` | — | Keep a history of triggered alerts. |
| `max_alert_history` | `100` | 10–500 | Maximum stored history entries. |
| `enable_notifications` | `false` | — | Show a toast notification for each alert. |

The alert monitor runs independently of the live-stream view: alerts are
raised even while the Log Monitor tab is closed.

## Privacy & Debugging

| Setting | Default | Description |
| ------------------ | ------- | ------------------------------------------------------------------------------------------------------- |
| `mask_log_content` | `false` | Mask API keys, passwords, tokens, and e-mail addresses in streamed lines before they reach the browser. |
| `debug_mode` | `false` | Enable verbose plugin logging and the debug endpoints (frontend event log, test entries). |

## Built-in limits

These are hard limits enforced by the backend regardless of settings:

- Log files larger than **1 GiB** are rejected for search and streaming.
- Search requests are rate limited to **10 per minute per client**.
- At most **20 files** per multi-stream request.
- Search `limit` parameter caps at **1000**; alert-history `limit` at **500**.
13 changes: 10 additions & 3 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,18 @@ Live log streaming and search for OctoPrint, with severity alerts in the navbar
- Real-time log streaming
- Full-text search with pagination and severity filters
- Navbar and sidebar alert badges
- Log download and alert history
- Log download, search-result export, and alert history

## Links
## Documentation

- [Plugin Overview](overview.md) — features and architecture
- [Configuration Reference](configuration.md) — every setting, default, and limit
- [REST API Reference](rest-api.md) — all plugin endpoints and push messages
- [Troubleshooting](troubleshooting.md) — common problems and fixes
- [Python API](api/python.md) — generated from docstrings

## Project

- [Plugin Overview](overview.md)
- [Contributing](contributing.md)
- [Security](security.md)
- [Changelog](changelog.md)
Expand Down
46 changes: 38 additions & 8 deletions docs/overview.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,45 @@
# Plugin Overview

OctoPrint Log Monitor streams OctoPrint logs, searches them with pagination and severity filters, and shows alert badges in the navbar and sidebar.
OctoPrint Log Monitor streams OctoPrint logs live, searches them with
pagination and severity filters, and shows alert badges in the navbar and
sidebar.

## Core features

- Live log streaming
- Search with severity filters
- Regex and case-sensitive search modes
- Log download and alert history
- Path traversal protection and input validation
- Live log streaming (single file from the UI, multiple files via the API)
- Full-text search with severity filters, regex and case-sensitive modes
- Background severity alerting with history, independent of the UI stream
- Log download and search-result export (CSV/TXT)
- Path traversal protection, rate limiting, and optional masking of
sensitive log content

## Source
## How it works

See the project README for the full plugin description and installation notes.
The backend consists of four small modules:

| Module | Responsibility |
| -------------- | ------------------------------------------------------------------------------------------------------- |
| `log_parser` | Single source of truth for parsing OctoPrint, serial, and compact log-line formats. |
| `log_tailer` | `tail -f`-style background thread per streamed file; detects rotation and truncation. |
| `log_searcher` | Streams through files line by line for search, stats, and exports — memory use is bounded by page size. |
| `security` | Filename/path validation, file-size guard, rate limiting, sensitive-data masking. |

The plugin core (`octoprint_logmonitor/__init__.py`) wires these together:

- **Live stream** — a tailer per streamed file pushes parsed lines into a
shared buffer, which is flushed to the browser as one batched WebSocket
message per poll interval.
- **Alert monitor** — separate tailers watch the configured log files and
raise `severity_alert` messages whenever a line matches the trigger
levels, even while the Log Monitor tab is closed.
- **REST API** — all routes live under `/plugin/logmonitor`; see the
[REST API reference](rest-api.md).

## Further reading

- [Configuration reference](configuration.md)
- [REST API reference](rest-api.md)
- [Troubleshooting](troubleshooting.md)
- [Python API](api/python.md)

See the project README for installation notes.
Loading