1.0.2 • Published 2 years ago

@strivexnl/simple-logger v1.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

Simple Logger

Just a wrapper around the console functions. Easy way to log message. Only logs when log level has been set.

Log levels

The available log levels are:

  • lvlNone
  • lvlError
  • lvlWarn
  • lvlInfo
  • lvlDebug
  • lvlTrace

We also have some combined levels, easy to use and less to write:

  • lvlAll All log levels combined.
  • lvlErrorWarnInfo (default) Only Error, Warn and Info levels
  • lvlDebugTrace Only Debug and Trace levels

Usage

Usage is straightforward:

import { SimpleLogger } from "SimpleLogger";

// Give the log levels you want as a parameter to the constructor.
const log = new SimpleLogger(SimpleLogger.lvlErrorWarnInfo);

// Call the log with the used loglevel.
log.log(SimpleLogger.lvlDebug, 'This is a debug message!');

// Or call the special method for each level directly.
log.logDebug('This is another debug message!');
log.logInfo('Some useful info message here!');

DateTime formatting.

Default the SimpleLogger uses "YYYY-MM-DD HH:mm:ss.SSS" as the default format. You can change that by using the second parameter in the constructor:

// Give the log levels you want as a parameter to the constructor.
const log = new SimpleLogger(SimpleLogger.lvlErrorWarnInfo, 'YYYYMMDD-HHmmss');
1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago