Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/RReverser/better-log
console.log wrapper for a bit more readable output in Node.js
https://github.com/RReverser/better-log
Last synced: 4 months ago
JSON representation
console.log wrapper for a bit more readable output in Node.js
- Host: GitHub
- URL: https://github.com/RReverser/better-log
- Owner: RReverser
- License: mit
- Created: 2015-05-22T09:54:26.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2018-08-03T14:25:54.000Z (over 6 years ago)
- Last Synced: 2024-08-08T16:13:41.838Z (4 months ago)
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/better-log
- Size: 8.79 KB
- Stars: 205
- Watchers: 7
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# better-log
**UPDATE: This is no longer necessary in Node.js 10.x.x as it colors output of `console.log` by default.**
console.log wrapper for a bit more readable output in Node.js
Tired of seeing hardly readable outputs like this?
![regular console.log](https://pbs.twimg.com/media/CFmZABUW0AAqAIK.png)
Replace them with something more elegant!
![better log](https://pbs.twimg.com/media/CFmZBRnWoAABjJi.png)
## Usage
### Patching built-in `console` (API is 100% compatible)
```javascript
require('better-log/install'); // ES6: import 'better-log/install';
console.log({ x: 1, y: 'prop' });
console.error('Something bad happened :(');
```or
```javascript
require('better-log').install({ depth: 2 }); // optional config
console.log({ x: 1, y: 'prop' });
console.error('Something bad happened :(');
```#### Restoring native `console.log` and `console.error`:
```javascript
require('better-log').uninstall();
```### Manual usage as a regular function
```javascript
var log = require('better-log')/* .setConfig({ depth: 2 }) */;
log({ x: 1, y: 'prop' });
log.error('Something bad happened :(');
```That's it!