bitnacle-io

1.2.3 • Public • Published

bitnacle-io

Build Status David David npm

bitnacle-io is a dead simple middleware logger to use with socket.io.

Installation

npm i bitnacle-io

Quick start

const io = require('socket.io')();
const bitnacleIo = require('bitnacle-io');
 
io.on('connection', socket => { 
    
    socket.use(bitnacleIo()); // use default "simple" format
 
    ...
 
});
 
io.listen(3000);

If you want to skip some events, you can do it by passing an array of event names to bitnacle-io and they won't be logged:

socket.use(bitnacleIo({
    exclude: [
        'event_name',
        'another_event_name',
        'yet_another_event_name'
    ]
}));

Formats

bitnacle-io uses 2 formats, simple (default) and json.

socket.use(bitnacleIo({
    format: 'json' // optional: default is "simple"
}));

simple format output:

[2019-08-25T20:01:11:130+0200] ["some_event",{"someKey":"someValue"}]

json format output:

{"time":"2019-08-25T20:02:43:125+0200","eventData":["some_event",{"someKey":"someValue"}]}

Dependents (0)

Package Sidebar

Install

npm i bitnacle-io

Weekly Downloads

8

Version

1.2.3

License

MIT

Unpacked Size

6.92 kB

Total Files

7

Last publish

Collaborators

  • daviddelpuerto