log-to-json

Yet another transform stream to convert .log files to .json.

Usage no npm install needed!

<script type="module">
  import logToJson from 'https://cdn.skypack.dev/log-to-json';
</script>

README

log-to-json

Yet another transform stream to convert .log files to .json.

Install

Requires Node >=10.

From npm,

npm i log-to-json

From Github Package Registry. (Guide).

Type definitions are bundled with this package.

Usage

This module uses streams, so you can handle large files.

const { LogToJSON } = require('log-to-json');
// or
import { LogToJSON } from 'log-to-json';

const converter = new LogToJSON();

fs.createReadStream('my.log')
  .pipe(converter)
  .pipe(fs.createWriteStream('my.log.json'));

my.log:

{"my": 5, "log":9, "file": "fsadf"}
{"my": 5, "log":9, "file": "fsadf"}
{"my": 5, "log":9, "file": "fsadf"}
{"my": 5, "log":9, "file": "fsadf"}

my.log.json:

[
  { "my": 5, "log": 9, "file": "fsadf" },
  { "my": 5, "log": 9, "file": "fsadf" },
  { "my": 5, "log": 9, "file": "fsadf" },
  { "my": 5, "log": 9, "file": "fsadf" }
]

Do not use this module if your your log files are not JSON like.


Licence

MIT © Vajahath Ahmed