tiny-track
v0.2.0
Published
A minimalistic dependency free logger
Maintainers
Readme
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';
// One stream
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-trackUsage
import { tinyTrack } from 'tiny-track';
// One stream
const tt = tinyTrack({
colorize: true,
format: 'json',
stream: process.stdout
}})
// Or multiple streams
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')),
},
])
// Browser compatible logger
const tt = tinyTrack({
colorize: false,
format: 'json', // or 'pretty'
}})
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 withw!` - debug -
tt\d![...]`, The message should start withd!`
