Tiny Track
A minimalistic dependency free logger that supports the transport of logs into multiple streams, and can also work both in the browser and in nodejs environments.
Besides, it provides other minimalistic approach to use logger through using tagged template:
import { tinyTrack } from 'tiny-track';
const tt = tinyTrack({
colorize: true,
format: 'json',
stream: process.stdout
}})
Where tt
is Tagged Template, which can take any numbers of placeholders with data you want to log.
Pretty format example
JSON format example
Install
npm install tiny-track
Usage
import { tinyTrack } from 'tiny-track';
const tt = tinyTrack({
colorize: true,
format: 'json',
stream: process.stdout
}})
const tt = tinyTrack([
{ colorize: true, stream: process.stdout, format: 'pretty', maxDepth: 5 },
{
level: ['debug', 'warn'],
colorize: false,
stream: fs.createWriteStream(path.resolve(process.cwd(), 'debug.log')),
},
{
level: 'error',
colorize: false,
stream: fs.createWriteStream(path.resolve(process.cwd(), 'error.log')),
},
])
const tt = tinyTrack({
colorize: false,
format: 'json',
}})
Log Levels
There are 4 log levels
- info (default) -
tt\
[...]`` - error -
tt\
![...]`, The exclamation mark
!` at the beginning indicates that is error - wann -
tt\
w![...]`, The message should start with
w!` - debug -
tt\
d![...]`, The message should start with
d!`