Update docs

This commit is contained in:
Raven Scott
2026-05-28 12:39:38 -04:00
parent 564029af44
commit 343102d4b5
15 changed files with 289 additions and 561 deletions
+8 -8
View File
@@ -15,7 +15,7 @@ This directory contains comprehensive documentation for the P2NS plugin system:
### SDK Features
- **[HYPERDB.md](HYPERDB.md)** - HyperDB database integration for plugins
- **[HYPERDRIVE.md](HYPERDRIVE.md)** - Hyperdrive distributed file system for plugins
- **[PLUGIN_CHANNELS.md](PLUGIN_CHANNELS.md)** - P2P communication channels via Protomux
- **[PLUGIN_CHANNELS.md](PLUGIN_CHANNELS.md)** - Plugin peer protocols via protomux-rpc
### Example Plugins
- **[example.plugin.md](example.plugin.md)** - Example Plugin template documentation
@@ -225,7 +225,7 @@ const ip = sdk.state.getIPForDomain('example.tld');
// Get all active Holesail connections
const holesails = sdk.state.holesails;
// Get peer channels
// Get swarm peer channels (plugin P2P uses sdk.channels, not this map)
const peerChannels = sdk.state.peerChannels;
// Get peer metrics
@@ -279,7 +279,7 @@ sdk.log.warn('my-plugin', 'Warning message');
sdk.log.error('my-plugin', 'Error message');
```
**Note:** Plugin logs are automatically broadcast to the admin interface and displayed in real-time in the plugin's log terminal. Logs are also written to `app.log` in the plugin directory.
**Note:** Plugin logs are written to `logs/plugins.log`, broadcast as `plugin-log` WebSocket messages (per-plugin terminal in admin), and appended to `plugin-sites/{domain}/app.log`.
### Core Operations
@@ -945,7 +945,7 @@ The SDK provides comprehensive access to all P2NS functionality:
- **`sdk.router`** - HTTP request parsing and response helpers
- **`sdk.admin`** - Admin panel registration (actions, settings)
- **`sdk.db`** - HyperDB database operations (see [HYPERDB.md](HYPERDB.md))
- **`sdk.channels`** - P2P communication channels (see [PLUGIN_CHANNELS.md](PLUGIN_CHANNELS.md))
- **`sdk.channels`** - Plugin protomux-rpc protocols (see [PLUGIN_CHANNELS.md](PLUGIN_CHANNELS.md))
- **`sdk.drives`** - Hyperdrive distributed file system (see [HYPERDRIVE.md](HYPERDRIVE.md))
### Admin Panel Registration
@@ -1030,7 +1030,7 @@ async handler(req, res) {
## Best Practices
1. **Error Handling**: Always wrap async operations in try-catch blocks
2. **Logging**: Use the SDK logging functions instead of console.log (logs appear in admin interface)
2. **Logging**: Use `sdk.log` instead of `console.log` (admin Plugins tab + `logs/plugins.log` and per-plugin `app.log`)
3. **Resource Cleanup**: Implement `onShutdown()` to clean up resources
4. **Security**: Validate and sanitize user input using `sdk.security`
5. **Performance**: Cache expensive operations when possible
@@ -1059,10 +1059,10 @@ Plugins can be managed via the admin interface at `https://p2ns.admin` in the Pl
- **Static**: Plugin only serves static files (no handler)
**Logs:**
- Plugin logs are displayed in real-time in the plugin's log terminal
- Logs are automatically captured from `sdk.log` calls
- Logs are also written to `app.log` in the plugin directory
- Plugin logs appear in the Plugins tab terminal and in `logs/plugins.log` (all plugins) plus `plugin-sites/{domain}/app.log`
- Logs are captured from `sdk.log` calls only (not `console.log`)
- Log terminals are hidden by default and appear when you start/stop/restart a plugin
- System-wide split logs (core, proxy, HTTP proxy, DNS, Holesail) are in the admin **Logs** tab — see [README_LONGFORM.md](../README_LONGFORM.md#logging-and-debugging)
## Troubleshooting