-
Notifications
You must be signed in to change notification settings - Fork 41
example code blue log source
The Code Blue window tails the WP debug log and the PHP error log out of the box. If your plugin writes its own log file, one filter puts it in the window's source picker — parsed, charted, and grouped like every other source:
add_filter( 'openstation_code_blue_log_sources', function ( $sources ) {
$upload_dir = wp_upload_dir();
$sources[] = array(
'id' => 'my-plugin-log',
'label' => __( 'My Plugin log', 'my-plugin' ),
'path' => trailingslashit( $upload_dir['basedir'] ) . 'my-plugin/debug.log',
);
return $sources;
} );That's the whole descriptor — id (slug), label, path (absolute). File metadata (exists, readable, writable, size, mtime) is derived server-side after filtering. A file that doesn't exist yet is treated as an empty log, not an error: it stays selectable in the picker (labelled "… (empty)") and serves zero entries until the first line is written. Only a file that exists but PHP cannot read is grayed out.
The parser understands standard error_log() output — [22-Aug-2026 09:14:02 UTC] … timestamps, PHP error labels, stack traces, and WordPress database error lines. Plain custom lines come through as one info entry per line, so a log of your own making is still searchable and groupable. Two format caveats:
-
Charting needs timestamps. Lines written with
error_log( $msg, 3, $path )carry no timestamp prefix, so they list and group but can't be placed on the histogram. Prepend the standard[d-M-Y H:i:s T]prefix when writing if you want your entries charted. -
Other formats can bring their own parser. If your file is Monolog- or ISO-formatted, hook
openstation_code_blue_entries— you get the raw scanned tail plus your source descriptor, and return your own entry array (build entries withopenstation_code_blue_make_entry()).
Two things to know:
-
The window is developer-mode, admin-only. Code Blue only registers when the user has Developer mode on in OpenStation Preferences AND
manage_options(manage_network_optionson multisite) — the sameopenstation_code_blue_user_can_usegate covers every source you register. Don't register a file whose content an administrator shouldn't see, because they will. - "Clear log" truncates your file. If the file is writable, the window offers to clear it. React if you need to:
add_action( 'openstation_code_blue_log_cleared', function ( $id, $path ) {
if ( 'my-plugin-log' === $id ) {
error_log( 'my-plugin: log cleared from the Code Blue window' );
}
}, 10, 2 );This wiki is generated from the docs/ directory — edits made here are overwritten by the next sync.
To change a page, open a pull request against docs/.
Guides
- Development guide
- Releasing openstation
- Agents security model
- API Index
- Architecture
- Bridge protocol — wiring overview
- <os-*> component reference
- Native Desktop Host — Experimental
- Desktop themes
- Dock customization — two registries, one mental model
- The event-driven framework
- Files on the Desktop
- Folder sharing
- Getting Started
- Hooks Reference
- Icons
- JavaScript Reference
- The Living Tree — algorithm definition
- Mio
- Native Windows & Framework Interop
- Plugin compatibility layer
- Progressive Web App (PWA)
- Station Home
- Using openstation from your own plugin
Migration notes
- Migration: built-in activity channels move to the os/ namespace
- Migration: window, wallpaper and widget bundles load on demand
- Migration — the navigation model
- Migration: a native window's tabs move to the window chrome
All examples
- AI Agents — extend and invoke from a plugin
- wp.os.ai.ask() — programmatic AI Copilot
- Tune the AI model config
- Custom arrange-menu action
- Open a child window its owner can't cover
- Style a specific admin page inside the iframe
- Code Blue — register your plugin's log file
- Open a file in the Code editor (deep-link from any window)
- Connect to a window — title-bar button + iframe pub/sub
- Content changes — live-refresh every window listing your type
- Custom window chrome (Experimental)
- Register a custom unfocused-window effect
- Example: render a data table
- Real file storage — react to uploads, gate policy, share from PHP
- React to a window being set free onto the real desktop
- Cross-window devtools — instrumentation primitives
- Add a dock item with a badge
- Decorate the dock without forking the renderer
- Replace the dock rail entirely
- Retune the Drafts widget's AI writing assistant
- Gate OpenStation by role
- Iframe-initiated window opens
- Build a feed reader without the bookkeeping
- Inject data into openStationConfig
- Render a list without losing clicks — renderKeyedList()
- Example: layout primitives (body → panel → row → col)
- Use <os-*> components from a plugin that ships as a zip
- Restyle and drive Mio
- Add an action that works on a whole selection
- WP Explorer — custom post types and their folder
- Add an action button to a WP Explorer preview pane
- Example: native Posts window
- Example: native window with tabs
- Native windows
- Customize note → post conversion
- Send a notification
- OAuth relay — connect to an external service
- OS-file drop
- <os-flyout> — window-scoped sliding card
- Plugins window — extras
- Track who's around — wp.os.presence
- Example: progress bar
- PWA install — surface your own button
- React to window events
- Example: extend the Trash
- Register a slash-command
- Register a desktop theme from a plugin
- Register a game
- Example: register a desktop icon (Jorvy)
- Register a wallpaper
- Register a widget
- Related entities — extend the title bar's "Related" menu
- The native-window render ctx
- Programmatic folder sharing
- Share state across multi-bundle plugins — wp.os.createSharedStore()
- Example: loading spinner
- Add an opt-in card to Station Home
- Accept drops on your desktop icon
- Give a tile two icons, one per state
- Add a row to a window's ⋯ menu
- Example: window activity & the status ring
- Window controls
- Subscribe to window lifecycle events
- Window links — relate windows and restyle the ties (Experimental)
- Window loading state — spinner overlay & ready signal
- Show a banner at the top of a window
- Pulse a window's icon — Window.requestAttention()
- Register a custom window reveal
- Window slots
- Window themes
- Native window with bundle-bound config