0.2.0 • Published 11 months ago

tiny-track v0.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

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 withw!`
  • debug - tt\d!...`, The message should start withd!`
0.2.0

11 months ago

0.1.0

12 months ago