loggerit
v1.1.3
Published
Typescript node package that wraps the global console
Downloads
1
Maintainers
Readme
loggerit
Typescript node package that wraps the node global console
.
- Simple to use
- For Typescript
Technical notes
- Written in Typescript and compiled in ECMAScript with target version ES2015 (aka ES6)
- Node.js >= 8.0.0
Level
Six different levels with the following weight order
- TRACE: prints to
stdout
- DEBUG: prints to
stdout
- INFO: prints to
stdout
- WARN: prints to
stderr
- ERROR: prints to
stderr
- FATAL: prints to
stderr
And a special one
- NONE: prints nothing to nowhere
Installation
$ npm install --save loggerit
Typescript example
Import
import { Logger, Level } from 'loggerit';
INFO level
const logger: Logger = new Logger(Level.INFO);
logger.write(Level.TRACE, 'trace');
logger.write(Level.DEBUG, 'debug');
logger.write(Level.INFO, 'info');
logger.write(Level.WARN, 'warn');
logger.write(Level.ERROR, 'error');
logger.write(Level.FATAL, 'fatal');
Console result
Only INFO, WARN, ERROR and FATAL logs are written
NONE level
logger.setLevel(Level.NONE);
logger.write(Level.TRACE, 'trace');
logger.write(Level.DEBUG, 'debug');
logger.write(Level.INFO, 'info');
logger.write(Level.WARN, 'warn');
logger.write(Level.ERROR, 'error');
logger.write(Level.FATAL, 'fatal');
Console result
No logs
From string to Level type
const level: Level = (<any>Level)['INFO'];
//const level: Level = (Level as any)['INFO'];
From Level to string type
const stringLevel: string = Level[Level.INFO];