tiny-track
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

Tiny Track

npm version

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

pretty format demo

JSON format example

json format demo

Install

npm install tiny-track

Usage

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 with w!`
  • debug - tt\d![...]`, The message should start with d!`

Package Sidebar

Install

npm i tiny-track

Weekly Downloads

0

Version

0.2.0

License

MIT

Unpacked Size

27.8 kB

Total Files

17

Last publish

Collaborators

  • alexej3ajtsev