The application should find all the log messages with the level error and print them into the output file. Formats of input and outfit files are described below.
- get log file location by parsing input flag (process argv)
- get output file location by parsing input flag (process argv)
- reads the log file line by line as ReadStream,
- Parse and convert to Log object.
- Publish selected log level(s) with observers. (Log level is dynamically changeable by updating filter.)
- Json Exporter which is one of observer of Log Reader will export logs in JSON format as WriteStream.
<ISO Date> - <Log Level> - {"transactionId: "<UUID>", "details": "<message event/action description>", "err": "<Optionall, error description>", ...<additional log information>}
[{"timestamp": <Epoch Unix Timestamp>, "loglevel": "<loglevel>", "transactionId: "<UUID>", "err": "<Error message>" }]
Before start program you have to add flags to script that is for running the application
Flag | Example | Description |
---|---|---|
--input |
./app.log | log file that will be parsed |
--output |
./errors.json | json file that is created after process |
install all dependencies via npm
npm install
build the app
npm run build
after installation ready to run program.
node dist/src/parser.js --input ./app.log --output ./errors.json