Slog or structured logging is a way to log data in a structured manner. This package makes sure you have a beutiful looking terminal while keeping your logs structured.
npm install good-slog
import { log, info, warning, error } from 'good-slog';
// or
const slog = require('good-slog');
log('Hello World');
To keep a record of all your logs, lets say in an object, you can call the callback function.
import { log } from 'good-slog';
const logs = [];
log('Hello World', (m) => logs.push(m));
To write to a file
import * as fs from 'fs';
import { log } from 'good-slog';
log('Hello World', (m) =>
fs.writeFileSync('logs.json', JSON.stringify(m))
);
There is a total of 4 exported functions.
log('Hello World');
info('Hello World');
warning('Hello World');
error('Hello World');