web-log-viewer 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/server.js
CHANGED
|
@@ -27,7 +27,7 @@ var path_1 = __importDefault(require("path"));
|
|
|
27
27
|
/**Contains all the logs that came into the server up until now */
|
|
28
28
|
var logs = [];
|
|
29
29
|
// setup the server
|
|
30
|
-
var app = express_1.default();
|
|
30
|
+
var app = (0, express_1.default)();
|
|
31
31
|
app.use(express_1.default.static(path_1.default.join(__dirname, 'public')));
|
|
32
32
|
var server = http_1.default.createServer(app);
|
|
33
33
|
var wss = new ws_1.default.Server({ server: server });
|
|
@@ -35,10 +35,10 @@ var wss = new ws_1.default.Server({ server: server });
|
|
|
35
35
|
server.listen(config_1.config.port, function () {
|
|
36
36
|
var address = server.address();
|
|
37
37
|
if (address) {
|
|
38
|
-
console.log("Started on "
|
|
38
|
+
console.log("Started on ".concat(typeof address == 'string' ? address : "".concat(address.port), ". Waiting for log messages on stdin..."));
|
|
39
39
|
// setup the log stream from stdin to clients
|
|
40
40
|
var logStream = setupLogStream()();
|
|
41
|
-
core_1.runEffects(logStream, scheduler_1.newDefaultScheduler());
|
|
41
|
+
(0, core_1.runEffects)(logStream, (0, scheduler_1.newDefaultScheduler)());
|
|
42
42
|
// waits for WS clients to connect
|
|
43
43
|
wss.on('connection', setupNewClient);
|
|
44
44
|
}
|
|
@@ -48,15 +48,15 @@ server.listen(config_1.config.port, function () {
|
|
|
48
48
|
* pipes them to all registered clients using websockets.
|
|
49
49
|
*/
|
|
50
50
|
var setupLogStream = function () {
|
|
51
|
-
return ramda_1.pipe(function () { return stream_utils_1.createReadlineStream(); },
|
|
51
|
+
return (0, ramda_1.pipe)(function () { return (0, stream_utils_1.createReadlineStream)(); },
|
|
52
52
|
// optionally log the message to the server's console
|
|
53
|
-
core_1.tap(function (rawMessage) {
|
|
53
|
+
(0, core_1.tap)(function (rawMessage) {
|
|
54
54
|
if (config_1.config.stdout) {
|
|
55
55
|
console.log(rawMessage);
|
|
56
56
|
}
|
|
57
57
|
}),
|
|
58
58
|
// parse the message with the currently configured parser
|
|
59
|
-
core_1.map(function (rawMessage) {
|
|
59
|
+
(0, core_1.map)(function (rawMessage) {
|
|
60
60
|
var data = config_1.config.parseRawMessage(rawMessage);
|
|
61
61
|
var msg = {
|
|
62
62
|
seq: logs.length + 1,
|
|
@@ -67,7 +67,7 @@ var setupLogStream = function () {
|
|
|
67
67
|
return msg;
|
|
68
68
|
}),
|
|
69
69
|
// potentially, send the message to all currently connected clients
|
|
70
|
-
core_1.tap(function (rawLog) {
|
|
70
|
+
(0, core_1.tap)(function (rawLog) {
|
|
71
71
|
wss.clients.forEach(function (ws) {
|
|
72
72
|
updateWsClientStatus(ws, function (status) {
|
|
73
73
|
var updateMsg = {
|
|
@@ -76,7 +76,7 @@ var setupLogStream = function () {
|
|
|
76
76
|
message: rawLog,
|
|
77
77
|
};
|
|
78
78
|
// only send the new message to the client if it passes the client's filter
|
|
79
|
-
var matcher = log_index_1.isIndexMatch(status.filter);
|
|
79
|
+
var matcher = (0, log_index_1.isIndexMatch)(status.filter);
|
|
80
80
|
if (matcher(updateMsg.message.index)) {
|
|
81
81
|
ws.send(encode(__assign(__assign({}, updateMsg), { message: __assign({}, updateMsg.message) })));
|
|
82
82
|
return __assign(__assign({}, status), { count: updateMsg.size });
|
|
@@ -115,7 +115,7 @@ function setupNewClient(ws) {
|
|
|
115
115
|
// - change the offset of static mode
|
|
116
116
|
ws.on('message', function (encodedMsg) {
|
|
117
117
|
var msg = decode(encodedMsg);
|
|
118
|
-
var matcher = log_index_1.isIndexMatch(msg.filter);
|
|
118
|
+
var matcher = (0, log_index_1.isIndexMatch)(msg.filter);
|
|
119
119
|
var filteredLogs = logs.filter(function (l) { return matcher(l.index); });
|
|
120
120
|
if (msg.mode == 'tail') {
|
|
121
121
|
updateWsClientStatus(ws, function (currentStatus) { return (__assign(__assign({}, currentStatus), { mode: 'tail', filter: msg.filter, count: filteredLogs.length })); });
|
package/build/stream-utils.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -36,7 +40,7 @@ var memoizedFromJson = function (s) {
|
|
|
36
40
|
};
|
|
37
41
|
exports.memoizedFromJson = memoizedFromJson;
|
|
38
42
|
var createReadlineStream = function () {
|
|
39
|
-
var _a = adapter_1.createAdapter(), induce = _a[0], readlineStream = _a[1];
|
|
43
|
+
var _a = (0, adapter_1.createAdapter)(), induce = _a[0], readlineStream = _a[1];
|
|
40
44
|
var rl = readline.createInterface({
|
|
41
45
|
input: process.stdin,
|
|
42
46
|
output: process.stdout,
|