1.0.0 • Published 8 months ago
good-slog v1.0.0
good-slog
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.
Installation
npm install good-slog
Usage
import { log, info, warning, error } from 'good-slog';
// or
const slog = require('good-slog');
Examples
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))
);
Functions
There is a total of 4 exported functions.
log
log('Hello World');
info
info('Hello World');
warning
warning('Hello World');
error
error('Hello World');
1.0.0
8 months ago