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

1.0.5 • Public • Published

envlog

A typescript console logger with an environment variable switch.

Features

  • set the environment key and value to match or inverse match.
  • optionally prints the line where the logger was called
  • smallest possible size and lightest cpu load

Usage

install

npm i envlog

import spawnLogger

import spawnLogger from 'envlog'

spawn a logger

Specify an environment variable to watch and then either an onValue OR offValue to match against.

const logger = spawnLogger({ envKey: string, // The key in environment variables to watch eg. 'LOGS' = process.env.LOGS onValue: string, // Log when environment value matches this value offValue: string, // Log when environment variable does not match this value stackTraceLines: number // Number of stack trace lines to show (Optional, default: 1) });

use the logger:

logger.log('example') logger.info(123) logger.warn({ key: 'val' }) logger.error([1, 2, 3])

Dependencies (0)

    Dev Dependencies (10)

    Package Sidebar

    Install

    npm i envlog

    Weekly Downloads

    1

    Version

    1.0.5

    License

    MIT

    Unpacked Size

    7.47 kB

    Total Files

    6

    Last publish

    Collaborators

    • xkore