2.1.0 • Published 3 years ago

@dfeprado/log v2.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

@dfeprado/log

Log utilty based on chalk (https://github.com/chalk/chalk)

Instalation

npm install @dfeprado/log

Basic usage

const { LogLevel, Log } = require('@dfeprado/log');

const log = new Log(LogLevel.all);

log.info('Hello world!'); // info log, green message
log.notice('Hello world!'); // notice log, purple message
log.warning('Hello world!'); // warning log, yellow message
log.error('Hello world!'); // error log, red message

Log levels

  • info
  • notice
  • warning
  • error
  • all

Examples:

Without file logging

const { LogLevel, Log } = require('@dfeprado/log');

let log = new Log(LogLevel.info | LogLevel.error); // Info and error only

log.info('Hello world!'); // print to stdout
log.error('Ohh!'); // print to stdout
log.warning('Warning!!!'); // do not print to stdout

log.close(); // gracefully closes log

With file logging

const { LogLevel, Log } = require('@dfeprado/log');

let log = new Log(LogLevel.all, '/var/log/log_sample');

log.error('Ohh!'); // write log to stdout and to /var/log/log_sample

log.close(); // gracefully closes log

Disabling stdout

const {LogLevel, Log} = require('@dfeprado/log');

let log = new Log(LogLevel.all, '/var/log/log_sample');
log.setStdoutOff();
log.Error('Hey! I cannot show myself in stdout!');

log.close();

Typescript usage

import { LogLevel, Log} from '@dfeprado/log';

let log: Log = new Log(LogLevel.all);

log.info('Hello world!');
log.close(); // gracefully closes log.

Every new ideas or sugestions are wellcomed.

2.1.0

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago