0.0.1-pre8 • Published 5 years ago

jsonrpclog v0.0.1-pre8

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

jsonrpclog

A utility for logging and viewing JSON-RPC v2 messages.

Usage

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.

Log Server

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.

Logging

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();

View Logs

The server runs on port 8085. If you're hosting it locally just go to localhost:8085.

License

MIT.

0.0.1-pre8

5 years ago

0.0.1-pre7

5 years ago

0.0.1-pre6

5 years ago

0.0.1-pre5

5 years ago

0.0.1-pre4

5 years ago

0.0.1-pre3

5 years ago

0.0.1-pre2

5 years ago

0.0.1-pre1

5 years ago