31 lines
762 B
JavaScript
31 lines
762 B
JavaScript
|
|
const http = require('http')
|
||
|
|
const readline=require('readline');
|
||
|
|
const rl = readline.createInterface({
|
||
|
|
input:process.stdin,
|
||
|
|
output:process.stdout,
|
||
|
|
terminal:false
|
||
|
|
});
|
||
|
|
|
||
|
|
const reTest= (regex,data)=>{
|
||
|
|
let match = regex.match(new RegExp('^/(.*?)/([giumy]*)$'));
|
||
|
|
regex = new RegExp(match[1], match[2]);
|
||
|
|
return regex.test(data);
|
||
|
|
}
|
||
|
|
|
||
|
|
// SourceTag
|
||
|
|
// ProcessingType
|
||
|
|
|
||
|
|
//let example='{ "sourceTag":"rpslog", "processingType":"casrpslog", "data":{"LogText":"Error"}}'
|
||
|
|
|
||
|
|
console.log(example);
|
||
|
|
rl.on('line', line=>{
|
||
|
|
let inputLine;
|
||
|
|
try {
|
||
|
|
inputLine = JSON.parse(line);
|
||
|
|
} catch (ex) {
|
||
|
|
console.error("Input not in JSON format:" + line);
|
||
|
|
}
|
||
|
|
console.log("line: " + reTest("/error/i",line));
|
||
|
|
})
|
||
|
|
|