-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: publish mini-console-logger v3
rewritten with TypeScript
- Loading branch information
Showing
2 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# mini-console-logger | ||
|
||
[![npm latest](https://img.shields.io/npm/v/mini-console-logger)](https://www.npmjs.com/package/mini-console-logger) | ||
[![npm prerelease](https://img.shields.io/npm/v/mini-console-logger/next?color=orange)](https://www.npmjs.com/package/mini-console-logger) | ||
![module formats: es, cjs](https://img.shields.io/badge/module%20formats-es%2C%20cjs-green) | ||
|
||
Simple logging utility. | ||
|
||
``` | ||
npm install mini-console-logger --save | ||
``` | ||
|
||
## Usage | ||
|
||
```js | ||
import logger, { LOG_LEVELS } from 'mini-console-logger'; | ||
|
||
logger.trace('trace'); | ||
logger.debug('debug'); | ||
logger.info('info'); | ||
logger.warn('warn'); | ||
logger.error('error'); | ||
|
||
// objects and Errors are stringified automatically | ||
logger.debug({ | ||
prop1: 'foo', | ||
prop2: 'bar' | ||
}); | ||
logger.error(new Error('foo')); | ||
|
||
logger.level = null; // silence logger | ||
logger.level = LOG_LEVELS.WARN; // log only warn and above | ||
|
||
logger.on(LOG_LEVELS.ERROR, err => { | ||
// do something with the error | ||
}); | ||
logger.off(LOG_LEVELS.ERROR); // unbind error listener | ||
``` | ||
|
||
[Live demo](https://jsbin.com/cawiwep/edit?js,console) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters