@ttoss/logger

0.3.4 • Public • Published

@ttoss/logger

Simple environment agnostic logger.

Motivation

Often, for debugging some piece of code, developers use console.log for it. When the application goes for production, some of these logs still appears, most because they forget to clear these logs. These package solves this, providing some levels of log that are emitted based on the environment of the application.

Log Levels vs Environments

Log Level Environment
Warn Dev-only
Error All
Info Dev-only

How to use

Just instantiate the logger, providing the isDev value configuration and start to use:

// createLogger.ts

import { Logger } from '@ttoss/logger';
import { config } from 'dotenv';

config();

export const createLogger = Logger(process.env.DEV === 'true');

// randomFile.ts

const logger = createLogger('randomFile');

logger.warn('This will emit an warn on console');

logger.error('This will emit a log of type error on console');

loggger.info('This will emit a simple log on console');

If you not pass any parameter to Logger, it gonna considers to be in dev environment:

// createLogger.ts

import { Logger } from '@ttoss/logger';

// In dev environment, gonna log everything
export const createLogger = Logger();

Readme

Keywords

none

Package Sidebar

Install

npm i @ttoss/logger

Weekly Downloads

6

Version

0.3.4

License

MIT

Unpacked Size

6.75 kB

Total Files

8

Last publish

Collaborators

  • pedro-arantes
  • techtriangulostecnologia