Skip to content

Add logging host functions for plugins - #8

Merged
gabek merged 4 commits into
mainfrom
gek/plugin-logging
Aug 2, 2026
Merged

Add logging host functions for plugins#8
gabek merged 4 commits into
mainfrom
gek/plugin-logging

Conversation

@gabek

@gabek gabek commented Aug 2, 2026

Copy link
Copy Markdown
Member

This adds ambient plugin logging functions so plugin authors can write operator-visible info, warning, and error entries without declaring a permission.

  • Add owncast.log.info, owncast.log.warning, and owncast.log.error
  • Include the plugin slug and severity in each host log entry
  • Add contract coverage, mocks, scenario log expectations, and chat-logger examples
Focused verification passed for issue #5083.

I ran the core Go tests and the JavaScript and Python chat-logger scenarios. The scenarios preserve all three log levels.

This branch is based on the SQL SDK change already on the stack where required. It does not change unrelated plugin behavior.

Fixes owncast/owncast#5083

Copilot AI review requested due to automatic review settings August 2, 2026 01:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR expands the Owncast Plugin SDK contract in two main areas: (1) ambient plugin-attributed server logging via owncast.log.* (no permission required), and (2) per-plugin SQLite storage via storage.sql/owncast.sql.*, including local/dev/scenario-host support so authors can test against SQL without a running Owncast server. It also updates scenario expectations, docs, and examples to exercise and document the new capabilities.

Changes:

  • Add ambient logging host functions and SDK facades: owncast.log.info, .warning, .error (JS + Python), plus scenario-level log expectations.
  • Add storage.sql permission + owncast.sql.exec/query/queryRow (JS) and exec/query/query_row (Python), including a pure-Go in-memory sqlstore for non-production hosts.
  • Update docs and examples (chat-logger, new chat-leaderboard) and normalize storage path documentation to data/plugin-storage/<slug>/....

Reviewed changes

Copilot reviewed 61 out of 65 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
sdks/python/owncast_plugin/template/AGENTS.md Documents storage.sql and adds SQL behavioral notes for Python plugin authors.
sdks/python/owncast_plugin/template/.agents/skills/create-owncast-plugin-py/SKILL.md Updates Python plugin-authoring skill docs with storage.sql and usage notes.
sdks/python/owncast_plugin/init.py Adds Python owncast.log facade and a new owncast.sql wrapper.
sdks/js/index.js Adds Permissions.StorageSQL, owncast.log.*, and owncast.sql.* JS wrappers; updates fs path docs.
sdks/js/index.d.ts Adds typings/docs for owncast.log and SQL types (SQLExecResult, SQLRow, etc.).
sdks/js/create-owncast-plugin/template/AGENTS.md Documents storage.sql and SQL behavior notes in JS scaffolding template.
sdks/js/create-owncast-plugin/template/.agents/skills/create-owncast-plugin-js/SKILL.md Updates JS plugin-authoring skill docs with storage.sql and usage notes.
host-runtime/sqlstore/sqlstore.go Introduces in-memory per-plugin SQLite store for non-production hosts using modernc.org/sqlite.
host-runtime/sqlstore/sqlstore_test.go Tests sqlstore’s value-size limit behavior matches production expectations.
host-runtime/plugin/testing/sql.go Wires sqlstore into the scenario/dev/mock host implementations.
host-runtime/plugin/testing/sql_test.go Adds tests for SQL round-trips, isolation, limits, and refusal parity.
host-runtime/plugin/testing/scenario.go Extends scenario expectations with ordered logs assertions.
host-runtime/plugin/testing/runner.go Adds log-level normalization + expectations checking for scenario logs; ensures SQL store cleanup.
host-runtime/plugin/testing/mocks.go Adds log recording and SQL exec/query hooks to the mock host.
host-runtime/main.go Adds demo-host plugin logging output and wires in-memory SQL backing; updates storage path docs.
host-runtime/go.sum Adds dependencies required for modernc.org/sqlite usage and bumps owncast module ref.
host-runtime/go.mod Adds modernc.org/sqlite and related indirect deps; bumps owncast module ref.
host-runtime/cmd/owncast-plugin-serve/main.go Adds plugin logging output, wires SQL store, updates dev storage root and fs sandbox path.
examples/python/README.md Adds the Python chat-leaderboard example to the examples index.
examples/python/file-manager/src/plugin.py Updates storage sandbox path references to plugin-storage/.../files/.
examples/python/file-manager/README.md Updates storage sandbox path references to plugin-storage/.../files/.
examples/python/file-manager/public/admin/index.html Updates displayed sandbox path to plugin-storage/.../files/.
examples/python/file-manager/INSTRUCTIONS.md Updates storage sandbox path references to plugin-storage/.../files/.
examples/python/chat-logger/src/plugin.py Switches from print to owncast.log.* and preserves severity based on message prefix.
examples/python/chat-logger/README.md Updates description to reflect owncast.log usage and severity behavior.
examples/python/chat-logger/plugin.manifest.json Updates description to reflect logging through Owncast server log.
examples/python/chat-logger/INSTRUCTIONS.md Updates usage instructions to show info/warning/error behaviors and attribution.
examples/python/chat-logger/tests/log.test.json Adds scenario expectations for ordered info/warning/error log entries.
examples/python/chat-leaderboard/src/plugin.py Adds a SQL-backed leaderboard example plugin (schema + queries + commands).
examples/python/chat-leaderboard/README.md Documents SQL-backed leaderboard behavior, limits, and rationale.
examples/python/chat-leaderboard/plugin.manifest.json Defines new example plugin manifest with storage.sql + chat.send.
examples/python/chat-leaderboard/INSTRUCTIONS.md Adds operator-facing instructions for commands and data location/retention.
examples/python/chat-leaderboard/tests/chat-leaderboard.test.json Adds scenario tests for leaderboard behavior and moderation gating.
examples/python/announcer/src/plugin.py Switches from print to owncast.log.info.
examples/python/announcer/README.md Updates documentation to reference server logging via owncast.log.info.
examples/python/announcer/INSTRUCTIONS.md Updates instructions to reference server logging via owncast.log.info.
examples/python/announcer/tests/announcer.test.json Adds scenario expectations for info-level logging.
examples/python/all-permissions-test/plugin.manifest.json Adds storage.sql to the “all permissions” manifest.
examples/js/README.md Adds the JS chat-leaderboard example to the examples index.
examples/js/file-manager/src/plugin.js Updates storage sandbox path references to plugin-storage/.../files/.
examples/js/file-manager/README.md Updates storage sandbox path references to plugin-storage/.../files/.
examples/js/file-manager/public/admin/index.html Updates displayed sandbox path to plugin-storage/.../files/.
examples/js/file-manager/INSTRUCTIONS.md Updates storage sandbox path references to plugin-storage/.../files/.
examples/js/chat-logger/src/plugin.js Switches from console.log to owncast.log.* and preserves severity based on message prefix.
examples/js/chat-logger/README.md Updates description to reflect owncast.log usage and severity behavior.
examples/js/chat-logger/plugin.manifest.json Updates description to reflect logging through Owncast server log.
examples/js/chat-logger/INSTRUCTIONS.md Updates usage instructions to show info/warning/error behaviors and attribution.
examples/js/chat-logger/tests/log.test.json Adds scenario expectations for ordered info/warning/error log entries.
examples/js/chat-leaderboard/src/plugin.js Adds a SQL-backed leaderboard example plugin (schema + queries + commands).
examples/js/chat-leaderboard/README.md Documents SQL-backed leaderboard behavior, limits, and rationale.
examples/js/chat-leaderboard/plugin.manifest.json Defines new example plugin manifest with storage.sql + chat.send.
examples/js/chat-leaderboard/package.json Adds package metadata/scripts for building/testing/serving the new example.
examples/js/chat-leaderboard/package-lock.json Locks dependencies for the new example.
examples/js/chat-leaderboard/INSTRUCTIONS.md Adds operator-facing instructions for commands and data location/retention.
examples/js/chat-leaderboard/tests/chat-leaderboard.test.json Adds scenario tests for leaderboard behavior and moderation gating.
examples/js/announcer/src/plugin.js Switches from console.log to owncast.log.info.
examples/js/announcer/README.md Updates documentation to reference server logging via owncast.log.info.
examples/js/announcer/INSTRUCTIONS.md Updates instructions to reference server logging via owncast.log.info.
examples/js/announcer/tests/announcer.test.json Adds scenario expectations for info-level logging.
examples/js/all-permissions-test/plugin.manifest.json Adds storage.sql to the “all permissions” manifest.
engines/javascript/engine.d.ts Adds host function declarations for owncast_log_* and owncast_sql_*.
engines/build_py.py Adds storage.sql host functions and new ambient logging host functions for Python engine builds.
docs/WIRE_PROTOCOL.md Documents storage.sql wire contract and adds ambient owncast_log_* host functions.
docs/PLUGIN_AUTHOR_GUIDE.md Documents owncast.log and storage.sql, updates permissions table and limits, updates examples.
docs/ARCHITECTURE.md Explains how non-production hosts implement SQL while matching production limits/refusals.
Files not reviewed (1)
  • examples/js/chat-leaderboard/package-lock.json: Generated file
Suppressed comments (3)

sdks/python/owncast_plugin/init.py:391

  • Same issue as info(): _host("owncast_log_warning") will tell authors to declare a permission if the function is missing, but logging is ambient. Missing support should report a host-capability issue, not a permissions issue.
    sdks/python/owncast_plugin/init.py:394
  • Same issue as info()/warning(): _host("owncast_log_error") will emit a permission-focused error if the host function is absent, which is confusing since owncast.log is ambient. It should fail with a host-compatibility message instead.
    sdks/js/index.js:647
  • For consistency with the Python SDK (and to avoid emitting invalid SQL request JSON), owncast.sql.exec should coerce sql to a string and normalize params to an array before JSON encoding.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread sdks/python/owncast_plugin/__init__.py Outdated
Comment thread sdks/js/index.js
@gabek

gabek commented Aug 2, 2026

Copy link
Copy Markdown
Member Author

The failed Toolchain check is an ordering dependency on owncast/owncast#5099. The workflow deliberately rebuilds host-runtime against owncast@develop, and develop does not have the new logging host symbols yet. I am not pinning the SDK to this unmerged core branch. Once #5099 merges, rerunning the check will compile against the required host API.

@gabek
gabek force-pushed the gek/plugin-logging branch from ed01c3a to 7a13828 Compare August 2, 2026 03:28
@gabek
gabek merged commit dd42a39 into main Aug 2, 2026
73 checks passed
@gabek
gabek deleted the gek/plugin-logging branch August 2, 2026 05:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Plugins Feature Request: Exported Host Functions for Logging

2 participants