webpack-log
Advanced tools
Comparing version 1.0.2 to 1.1.0
18
index.js
@@ -6,2 +6,3 @@ 'use strict'; | ||
const logSymbols = require('log-symbols'); | ||
const uuid = require('uuid/v4'); | ||
@@ -22,3 +23,4 @@ const symbols = { | ||
template: `{{level}} ${chalk.gray('「{{name}}」')}: ` | ||
} | ||
}, | ||
unique: true | ||
}; | ||
@@ -29,2 +31,8 @@ | ||
Object.defineProperty(opts, 'id', { | ||
get() { | ||
return this.name + (opts.unique ? `-${uuid()}` : ''); | ||
} | ||
}); | ||
if (opts.timestamp) { | ||
@@ -36,2 +44,10 @@ opts.prefix.template = `[{{time}}] ${opts.prefix.template}`; | ||
if (!Object.prototype.hasOwnProperty.call(log, 'id')) { | ||
Object.defineProperty(log, 'id', { | ||
get() { | ||
return opts.id; | ||
} | ||
}); | ||
} | ||
return log; | ||
@@ -38,0 +54,0 @@ }; |
{ | ||
"name": "webpack-log", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"description": "A common logging module for the Webpack ecosystem", | ||
@@ -34,3 +34,4 @@ "license": "MIT", | ||
"log-symbols": "^2.1.0", | ||
"loglevelnext": "^1.0.0" | ||
"loglevelnext": "^1.0.1", | ||
"uuid": "^3.1.0" | ||
}, | ||
@@ -37,0 +38,0 @@ "devDependencies": { |
@@ -48,5 +48,9 @@ <div align="center"> | ||
The default export (`function`) accepts an `options` Object. The following is a property reference | ||
for the Object. | ||
The default export (`function`) will return a logger, given an `options` Object. | ||
The following is a property reference for the Object. | ||
_Note: the logger returned is unique by default, due to the nature of the `webpack` | ||
ecosystem. Please reference the [`unique`](#unique) option below for disabling | ||
this feature and to force caching._ | ||
### level | ||
@@ -92,2 +96,13 @@ | ||
### unique | ||
Type: `Boolean` | ||
Default: `true` | ||
If `false`, instructs the logger to used cached versions of a log with the same | ||
name. Due to the nature of the `webpack` ecosystem and multiple plugin/loader | ||
use in the same process space, loggers are created as unique instances by default. | ||
By passing `false` for this property, the module is instructed to cache the | ||
requested logger. | ||
## Contributing | ||
@@ -94,0 +109,0 @@ |
7134
50
133
4
+ Addeduuid@^3.1.0
+ Addeduuid@3.4.0(transitive)
Updatedloglevelnext@^1.0.1