Skip to content

Commit

Permalink
v1.1.0. Bug fixes and some more docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
cb1kenobi committed Feb 10, 2017
1 parent 431cf65 commit 16d6f57
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ Laid back logging.
* Ability to snoop on other snooplogg instances nested in dependencies
* Pipe messages to one or more streams
* Namespacing
* Filter messages using the `DEBUG` environment variable
* Filter messages using the `DEBUG` (or `SNOOPLOGG`) environment variable
* Includes helper libraries for your convenience
* [chalk](https://www.npmjs.com/pacakge/chalk)
* [figures](https://www.npmjs.com/package/figures) (exported as `symbols`)
* [humanize](https://www.npmjs.com/package/humanize)
* [moment](https://www.npmjs.com/package/moment)
* Similar API to [TJ's debug](https://www.npmjs.com/package/debug)
* Similar API to [TJ's debug](https://www.npmjs.com/package/debug):
* `const debug = snooplogg('myapp').log;`

## Examples

Expand Down Expand Up @@ -78,6 +79,9 @@ $ DEBUG=izzle node loggfather.js
> node loggfather.js
```

> Note: You may also use the `SNOOPLOGG` environment variable to avoid conflicts
> with other libraries that use [debug](https://www.npmjs.com/package/debug)
Listen for messages from all `SnoopLogg` instances, even from other
dependencies.

Expand Down Expand Up @@ -111,6 +115,18 @@ log.jin('parents ain\'t home');
log.juice('too much drama', true);
```

### API

#### `snooplogg()`

Creates a namespaced logger as well as defines the global namespaced logger.

#### `snooplogg.log(msg)`

Outputs a message using the standard `console.log()` format syntax.

*More docs to come in the future!*

## License

(The MIT License)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "snooplogg",
"version": "1.0.0",
"version": "1.1.0",
"description": "Your mind on your logs and your logs on your mind",
"main": "./dist/index.js",
"author": "Chris Barber <chris@cb1inc.com> (https://github.com/cb1kenobi)",
Expand Down
12 changes: 5 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ class SnoopLogg extends Logger {
* The default theme to apply if a stream didn't specify one.
* @type {String}
*/
_defaultTheme: { writable: true, value: 'minimal' },
_defaultTheme: { writable: true, value: 'standard' },

/**
* A lazy unique identifier for this `SnoopLogg` instance. This
Expand Down Expand Up @@ -807,20 +807,18 @@ function createInstanceWithDefaults() {

// create the global instance and wire up the built-in types
let instance = createInstanceWithDefaults()
.enable(process.env.DEBUG)
.enable(process.env.SNOOPLOGG || process.env.DEBUG)
.pipe(new StdioStream, { flush: true });

const snooplogg = instance.bind(instance);

// bind all methods to the main instance
for (const i of Object.getOwnPropertyNames(SnoopLogg.prototype)) {
if (typeof SnoopLogg.prototype[i] === 'function') {
snooplogg[i] = instance[i].bind(instance);
instance[i] = instance[i].bind(instance);
}
}

exports = module.exports = snooplogg;
exports = module.exports = instance;

export default snooplogg;
export default instance;

export { createInstanceWithDefaults, Format, Logger, SnoopLogg, StripColors };
2 changes: 1 addition & 1 deletion test/test-snoop.js
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ describe('SnoopLogg', () => {
class MockOutputStream extends Writable {
_write(msg, enc, cb) {
count++;
expect(msg.toString()).to.equal('foo() test\n');
expect(msg.toString()).to.equal('foo foo() test\n');
cb();
}
}
Expand Down

0 comments on commit 16d6f57

Please sign in to comment.