A utility for logging and viewing JSON-RPC v2 messages.
The logging system is composed of a standalone server and a package that relays the messages to the server. These messages can then be viewed via a live web interface.
git clone https://github.com/Fylipp/jsonrpclog
cd jsonrpclog
npm install
npm start
The server can be configured via the config.json
file. Optionally, SSL can be configured
for the web interface and log data transmission.
When you are satisfied you must restart the server.
Install the package:
npm install jsonrpclog
And integrate it into your application:
const jsonrpclog = require('jsonrpclog')(); // Connects to localhost by default
// Messages to and from peer 1
jsonrpclog.out(1, {jsonrpc: '2.0', id: 1, method: 'add', params: [2, 3]});
jsonrpclog.in(1, {jsonrpc: '2.0', id: 1, result: 5});
// Messages to and from peer 'bob'
jsonrpclog.in('bob', {jsonrpc: '2.0', id: 1, method: 'sub', params: [10, 'bar']]});
jsonrpclog.out('bob', {jsonrpc: '2.0', id: 1, error: 'Arguments must be numeric'});
// Notification message to alice
jsonrpclog.out('alice', {jsonrpc: '2.0', method: 'hello', params: 'Good day!'});
// Batches also work
jsonrpclog.out('chris', [
{jsonrpc: '2.0', id: 4, method: 'add', params: [5, 6]},
{jsonrpc: '2.0', id: 5, method: 'subtract', params: [5, 6]}
]);
jsonrpclog.in('chris', [
{jsonrpc: '2.0', id: 4, result: 11},
{jsonrpc: '2.0', id: 5, result: -1}
]);
// Clear the entire log
jsonrpclog.clear();
// Close the connection
jsonrpclog.close();
The server runs on port 8085
. If you're hosting it locally just go to localhost:8085.
MIT.