Files
logAggregator/index.js
2019-01-02 14:22:10 -06:00

35 lines
854 B
JavaScript

const micro = require('micro')
const {json,send} = require('micro')
const reTest= (regex,data)=>{
let match = regex.match(new RegExp('^/(.*?)/([giumy]*)$'));
regex = new RegExp(match[1], match[2]);
return regex.test(data);
}
// SourceTag
// ProcessingType
const server = micro(async (req,res) => {
//console.log(req);
const js = await json(req);
//console.log("Received Data",js);
try {
inputLine = JSON.parse(js);
} catch (ex) {
console.error("Input not in JSON format:" + line);
}
if (inputLine.processingType==="casrpslog") {
if (inputLine.data.Severity > 1 ) {
console.log("Issue ",inputLine.data.LogText);
}
}
//console.log("line: " + reTest("/error/i",inputLine));
send(res,200,"OK");
});
server.listen(2222);