datto / json-rpc-log
Logged server extension for JSON-RPC library
Installs: 10 856
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 6
Forks: 1
Open Issues: 1
Requires
- datto/json-rpc: ~3.0
- monolog/monolog: ~1.0
Requires (Dev)
- datto/json-rpc-simple: ~4.0
This package is not auto-updated.
Last update: 2024-12-21 19:47:42 UTC
README
This is a logger extension for the php-json-rpc library. It provides a simple logging mechanism to log incoming JSON-RPC requests and the corresponding responses to a logger.
Examples
To use the logged server, simply create a logger with a corresponding handler and pass it to a Logger\Server
instance. In this example, we'll use Monolog's SyslogHandler
and the Simple\Evaluator
(see php-json-rpc-simple). This will log all requests and the responses to the system's syslog, typically found at /var/log/syslog
:
<?php use Datto\JsonRpc\Logged; use Datto\JsonRpc\Simple; use Monolog\Handler\SyslogHandler; use Monolog\Logger; $server = new Logged\Server( new Simple\Evaluator(), new Logger('API', array(new SyslogHandler('datto.api'))) ); $server->reply('{"jsonrpc": "2.0", "method": "math/subtract", "params": [6, 2], "id": 1}');
Requirements
- PHP >= 5.3
Installation
"require": { "datto/json-rpc-log": "~4.0" }
License
This package is released under an open-source license: LGPL-3.0.
Author
Written by Philipp C. Heckel.