@@ -64,31 +64,33 @@ The logging component supports writing to various destinations:
6464### Available Destinations
6565
6666- ** Echo** : Output to browser/console
67+ - ** Email** : Send logs via email
6768- ** File** : Write to log files
68- - ** StdOut** : Write to standard output
69- - ** StdErr** : Write to standard error
70- - ** StdOutStdErr** : Write to both stdout and stderr based on level
71- - ** SysLog** : System logging
7269- ** Memory** : Store logs in memory for testing
70+ - ** Nightwatch** : Send to Laravel Nightwatch monitoring service
7371- ** Null** : Discard logs (useful for testing)
74- - ** Email ** : Send logs via email
72+ - ** Papertrail ** : Send to Papertrail cloud logging service
7573- ** Slack** : Post to Slack channels
76- - ** Webhook** : Send to custom webhooks
7774- ** Socket** : Send over network sockets
78- - ** Nightwatch** : Send to Laravel Nightwatch monitoring service
75+ - ** StdErr** : Write to standard error
76+ - ** StdOut** : Write to standard output
77+ - ** StdOutStdErr** : Write to both stdout and stderr based on level
78+ - ** SysLog** : System logging
79+ - ** Webhook** : Send to custom webhooks
80+ - ** WebSocket** : Stream logs in real-time via WebSocket
7981
8082### Formats
8183
8284Each destination can use different formatting:
8385
84- - ** PlainText** : Human-readable text format
85- - ** JSON** : Structured JSON output
8686- ** CSV** : Comma-separated values
8787- ** HTML** : HTML formatted output
8888- ** HTMLEmail** : HTML optimized for emails
89+ - ** JSON** : Structured JSON output
90+ - ** Nightwatch** : Laravel Nightwatch-specific JSON formatting
91+ - ** PlainText** : Human-readable text format
8992- ** Raw** : Unformatted output
9093- ** Slack** : Slack-specific formatting
91- - ** Nightwatch** : Laravel Nightwatch-specific JSON formatting
9294
9395## Usage Examples
9496
@@ -264,6 +266,87 @@ Log::channel( 'payments' )->error( 'Payment failed', [ 'amount' => 99.99 ] );
264266
265267The channel name appears in the Nightwatch dashboard for easy filtering and monitoring.
266268
269+ ### Papertrail Integration
270+
271+ Papertrail is a cloud-based logging service that aggregates and centralizes logs from multiple sources. The Papertrail destination sends logs using the remote syslog protocol with optional TLS encryption.
272+
273+ ``` php
274+ use Neuron\Log\Logger;
275+ use Neuron\Log\Destination\Papertrail;
276+ use Neuron\Log\Format\PlainText;
277+
278+ // Create Papertrail destination
279+ $papertrail = new Papertrail( new PlainText() );
280+ $papertrail->open( [
281+ 'host' => 'logs5.papertrailapp.com', // Your Papertrail host
282+ 'port' => 12345, // Your Papertrail port
283+ 'system_name' => 'my-app-prod', // Optional: System name (defaults to hostname)
284+ 'use_tls' => true, // Optional: Use TLS encryption (default: true)
285+ 'facility' => 16, // Optional: Syslog facility (default: 16 for local0)
286+ 'sd_id' => 'mycompany@12345' // Optional: Structured Data ID (default: 'neuron@32473')
287+ ] );
288+
289+ $papertrailLogger = new Logger( $papertrail );
290+ $papertrailLogger->setRunLevel( 'info' );
291+
292+ // Logs are sent to Papertrail with structured data
293+ $papertrailLogger->error( 'Payment processing failed', [
294+ 'transaction_id' => 'txn_12345',
295+ 'amount' => 99.99,
296+ 'currency' => 'USD',
297+ 'error_code' => 'INSUFFICIENT_FUNDS'
298+ ] );
299+
300+ // Context is included as structured data in syslog format
301+ $papertrailLogger->info( 'User action', [
302+ 'user_id' => 456,
303+ 'action' => 'purchase',
304+ 'items' => [ 'SKU-123', 'SKU-456' ]
305+ ] );
306+ ```
307+
308+ The Papertrail destination:
309+ - Sends logs using RFC 5424 syslog format over TCP/TLS
310+ - Automatically maps log levels to syslog severities
311+ - Includes context as structured data for easy filtering in Papertrail
312+ - Supports automatic reconnection if the connection is lost
313+ - Allows custom SD-ID for organizations with IANA Private Enterprise Numbers
314+
315+ ### WebSocket Real-Time Streaming
316+
317+ Stream logs in real-time to web browsers or monitoring dashboards using WebSocket connections:
318+
319+ ``` php
320+ use Neuron\Log\Logger;
321+ use Neuron\Log\Destination\WebSocket;
322+ use Neuron\Log\Format\JSON;
323+
324+ // Create WebSocket destination
325+ $websocket = new WebSocket( new JSON() );
326+ $websocket->open( [
327+ 'url' => 'ws://localhost:8080/logs', // WebSocket server URL
328+ 'max_reconnect_attempts' => 5, // Optional: Max reconnection attempts (default: 5)
329+ 'reconnect_delay' => 1.0 // Optional: Initial reconnect delay in seconds
330+ ] );
331+
332+ $wsLogger = new Logger( $websocket );
333+ $wsLogger->setRunLevel( 'debug' );
334+
335+ // Logs are streamed in real-time to connected WebSocket clients
336+ $wsLogger->info( 'Real-time event', [
337+ 'event_type' => 'user_login',
338+ 'user_id' => 123,
339+ 'timestamp' => time()
340+ ] );
341+ ```
342+
343+ The WebSocket destination:
344+ - Maintains persistent WebSocket connections
345+ - Automatically reconnects with exponential backoff
346+ - Sends logs as WebSocket text frames
347+ - Perfect for real-time monitoring dashboards
348+ - Works with any WebSocket server implementation
349+
267350### Array Context Support (PSR-3 Compatible)
268351
269352``` php
0 commit comments