Skip to content

buggregator/monolog-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Monolog Server Plugin for RoadRunner

A RoadRunner plugin that provides a TCP server for receiving Monolog log records via the SocketHandler.

How it works

The plugin starts a TCP server that accepts newline-delimited JSON log records from Monolog's SocketHandler. Each received record is parsed and pushed to RoadRunner's Jobs plugin for processing by your PHP application.

Configuration

monolog:
  addr: ":9913"
  max_message_size: 10485760  # 10MB
  jobs:
    pipeline: "monolog"
    auto_ack: true

Configuration Options

Option Default Description
addr 127.0.0.1:9913 TCP server listen address
read_timeout 60s Connection read timeout
max_message_size 10485760 (10MB) Maximum message size in bytes
jobs.pipeline (required) Target Jobs pipeline name
jobs.priority 10 Default job priority
jobs.delay 0 Default job delay
jobs.auto_ack false Auto-acknowledge jobs

PHP Client Configuration

Configure Monolog's SocketHandler to send logs to this server:

use Monolog\Handler\SocketHandler;
use Monolog\Formatter\JsonFormatter;

$handler = new SocketHandler('tcp://127.0.0.1:9913');
$handler->setFormatter(new JsonFormatter());
$logger->pushHandler($handler);

Job Format

Each log record is pushed as a job named monolog.log with the following payload structure:

{
  "event": "LOG_RECEIVED",
  "uuid": "unique-id",
  "client_id": 1,
  "remote_addr": "127.0.0.1:54321",
  "received_at": "2024-01-01T00:00:00Z",
  "payload": {
    "message": "Log message",
    "context": {},
    "level": 200,
    "level_name": "INFO",
    "channel": "app",
    "datetime": "2024-01-01T00:00:00+00:00",
    "extra": {}
  },
  "project": "my-project"
}

License

MIT License. See LICENSE for details.

About

RoadRunner plugin for receiving Monolog log records via TCP

Resources

License

Code of conduct

Stars

Watchers

Forks

Contributors

Languages