Log all packets recieved on server
This commit is contained in:
parent
648132aa2b
commit
671d0a3b69
@ -1,6 +1,7 @@
|
|||||||
const WebSocket = require('ws');
|
const WebSocket = require('ws');
|
||||||
let net = require('net');
|
const net = require('net');
|
||||||
let aprs = require("aprs-parser");
|
const aprs = require("aprs-parser");
|
||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
const parser = new aprs.APRSParser();
|
const parser = new aprs.APRSParser();
|
||||||
const client = new net.Socket();
|
const client = new net.Socket();
|
||||||
@ -27,8 +28,11 @@ client.on('data', function(data) {
|
|||||||
if (!packet.startsWith('#')) { // ignore comments
|
if (!packet.startsWith('#')) { // ignore comments
|
||||||
let message = parser.parse(packet);
|
let message = parser.parse(packet);
|
||||||
let date = new Date();
|
let date = new Date();
|
||||||
|
let datestamp = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate();
|
||||||
message.recieved = date;
|
message.recieved = date;
|
||||||
console.log(message);
|
console.log(message);
|
||||||
|
fs.appendFile("log" + datestamp + ".json", JSON.stringify(message) + ",\n",
|
||||||
|
err => {if (err) throw err;});
|
||||||
wss.broadcast(JSON.stringify(message));
|
wss.broadcast(JSON.stringify(message));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user