9.1.10 • Published 18 days ago

ut-port-console v9.1.10

Weekly downloads
7
License
Apache-2.0
Repository
github
Last release
18 days ago

ut-port-console

'ut-port-console' is a module aimed to provide logs monitoring web interface for UT5 implementations. 'ut-port-console' works in cooperation with 'ut-log' (see 'ut-log' docs for more info). In order the two modules to be successfully bundled together a 'soketStream' stream/transport should be enabled for the 'ut-log' instance in a way that it creates a socket client which binds to console's host and port. The following code can be used for bundling the ut-log module with the ut-port-console interface:

var utLog = require('ut-log');
var utPortConsole = require('ut-port-console');
var SocketStream = require('ut-log/socketStream');
var consoleHost = '127.0.0.1';
var consolePort = '30001';
// ut-log
var utLogConfig = {
    type: 'bunyan',
    streams: [
        {
            level: 'trace',
            stream: new SocketStream({
                host: consoleHost,
                port: consolePort,
                objectMode: true
            }),
            type: 'raw'
        }
    ]
};
var logFactory = new utLog(utLogConfig);
var log = logFactory.createLog('info', {name: 'a', context: 'b'});
//ut-port-console
var consoleInstance = new utPortConsole();
consoleInstance.config.host = consoleHost;
consoleInstance.config.port = consolePort;
consoleInstance.init();
consoleInstance.start();

Then each message the logFactory instance logs will be sent to the console client through a websocket connection simultaneously.

i.e.

log.info('test');

will stream the message 'test' to the console.

Storing logs to LevelDB

'ut-log' and 'ut-port-console' can be configured in a way to share a common LevelDB database which can be used for storing and querying log messages. For this purpose a 'LevelDBStream' stream/transport should be added to the logger which share a common database instance with the console port. The following code demonstrates how that could be achieved:

var utLog = require('ut-log');
var level = require('level');
var utPortConsole = require('ut-port-console');
var SocketStream = require('ut-log/socketStream');
var LevelDBStream = require('ut-log/leveldbStream');
var consoleHost = '127.0.0.1';
var consolePort = '30001';
var logsDB = level('./logs');
// ut-log
var utLogConfig = {
    type: 'bunyan',
    streams: [
        {
            level: 'trace',
            stream: new SocketStream({
                host: consoleHost,
                port: consolePort,
                objectMode: true
            }),
            type: 'raw'
        },
        {
            level: 'trace',
            stream: new LevelDBStream(logsDB),
            type: 'raw'
        }
    ]
};
var logFactory = new utLog(utLogConfig);
var log = logFactory.createLog('info', {name: 'a', context: 'b'});
//ut-port-console
var consoleInstance = new utPortConsole();
consoleInstance.config.host = consoleHost;
consoleInstance.config.port = consolePort;
consoleInstance.db = logsDB;
consoleInstance.init();
consoleInstance.start();

Then each message the logFactory instance logs will be sent to the console client through a websocket connection and will be stored in './logs' leveldb database simultaneously.

i.e.

log.info('leveldb test')

will stream the message 'leveldb test' to the console and will store it to the db.

9.1.10

18 days ago

9.1.9

11 months ago

9.1.8

1 year ago

9.1.7

2 years ago

9.1.6

3 years ago

9.1.5

3 years ago

9.1.4

3 years ago

9.1.3

3 years ago

9.1.2

4 years ago

9.1.1

4 years ago

9.1.0

5 years ago

9.0.2

5 years ago

9.0.1

5 years ago

9.0.0

5 years ago

8.2.3

5 years ago

8.2.2

5 years ago

8.2.1

5 years ago

8.2.0

5 years ago

8.1.0

6 years ago

8.0.0

6 years ago

7.0.1

6 years ago

7.0.0

6 years ago

7.0.0-ut6.2

6 years ago

7.0.0-ut6.1

6 years ago

7.0.0-ut6.0

7 years ago

6.4.0

7 years ago

6.4.0-rc.1

7 years ago

6.4.0-rc.0

7 years ago

6.3.8

7 years ago

6.3.7

7 years ago

6.3.7-ws.7

7 years ago

6.3.7-ws.6

7 years ago

6.3.7-ws.5

7 years ago

6.3.7-ws.4

7 years ago

6.3.7-ws.3

7 years ago

6.3.7-ws.2

7 years ago

6.3.7-ws.1

7 years ago

6.3.7-ws.0

7 years ago

6.3.5

7 years ago

6.3.4

7 years ago

6.3.3

7 years ago

6.3.2

7 years ago

6.3.1

7 years ago

6.3.0

7 years ago

6.2.13

7 years ago

6.2.12

7 years ago

6.2.11

7 years ago

6.2.10

7 years ago

6.2.9

7 years ago

6.2.8

7 years ago

6.2.7

7 years ago

6.2.6

7 years ago

6.2.5

7 years ago

6.2.4

7 years ago

6.2.3

7 years ago

6.2.2

7 years ago

6.2.1

7 years ago

6.2.0

7 years ago

6.1.12

7 years ago

6.1.11

7 years ago

6.1.10

7 years ago

6.1.9

7 years ago

6.1.8

7 years ago

6.1.7

7 years ago

6.1.6

7 years ago

6.1.5

8 years ago

6.1.4

8 years ago