Skip to content

Commit 7b2e4fd

Browse files
committed
3.1.0
1 parent f631ee0 commit 7b2e4fd

File tree

6 files changed

+35
-39
lines changed

6 files changed

+35
-39
lines changed

dist/logdown.js

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ module.exports = function () {
1414
this.opts = Logdown._normalizeOpts(prefix, opts)
1515
this.state = Logdown._getInitialState(this.opts)
1616

17+
Logdown._decorateLoggerMethods(this)
1718
Logdown._instances.push(this)
1819

1920
return this
@@ -87,26 +88,23 @@ module.exports = function () {
8788
return isEnabled
8889
}
8990

90-
//
91-
// Instance
92-
//
93-
94-
var methods = ['debug', 'log', 'info', 'warn', 'error']
95-
methods.forEach(function (method) {
96-
Logdown.prototype[method] = function () {
97-
if (!this.state.isEnabled) {
98-
return
99-
}
91+
Logdown._decorateLoggerMethods = function (instance) {
92+
Object.keys(instance.opts.logger).forEach(function (method) {
93+
instance[method] = function () {
94+
if (!this.state.isEnabled) {
95+
return
96+
}
10097

101-
var args = toArray(arguments)
102-
var preparedOutput = this._prepareOutput(args, method)
98+
var args = toArray(arguments)
99+
var preparedOutput = this._prepareOutput(args, method)
103100

104-
;(this.opts.logger[method] || this.opts.logger.log).apply(
105-
this.opts.logger,
106-
preparedOutput
107-
)
108-
}
109-
}, this)
101+
;(this.opts.logger[method] || this.opts.logger.log).apply(
102+
this.opts.logger,
103+
preparedOutput
104+
)
105+
}
106+
})
107+
}
110108

111109
return Logdown
112110
}

dist/logdown.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/logdown.min.js.gzip

6 Bytes
Binary file not shown.

example/lib/logdown.js

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ module.exports = function () {
1414
this.opts = Logdown._normalizeOpts(prefix, opts)
1515
this.state = Logdown._getInitialState(this.opts)
1616

17+
Logdown._decorateLoggerMethods(this)
1718
Logdown._instances.push(this)
1819

1920
return this
@@ -87,26 +88,23 @@ module.exports = function () {
8788
return isEnabled
8889
}
8990

90-
//
91-
// Instance
92-
//
93-
94-
var methods = ['debug', 'log', 'info', 'warn', 'error']
95-
methods.forEach(function (method) {
96-
Logdown.prototype[method] = function () {
97-
if (!this.state.isEnabled) {
98-
return
99-
}
91+
Logdown._decorateLoggerMethods = function (instance) {
92+
Object.keys(instance.opts.logger).forEach(function (method) {
93+
instance[method] = function () {
94+
if (!this.state.isEnabled) {
95+
return
96+
}
10097

101-
var args = toArray(arguments)
102-
var preparedOutput = this._prepareOutput(args, method)
98+
var args = toArray(arguments)
99+
var preparedOutput = this._prepareOutput(args, method)
103100

104-
;(this.opts.logger[method] || this.opts.logger.log).apply(
105-
this.opts.logger,
106-
preparedOutput
107-
)
108-
}
109-
}, this)
101+
;(this.opts.logger[method] || this.opts.logger.log).apply(
102+
this.opts.logger,
103+
preparedOutput
104+
)
105+
}
106+
})
107+
}
110108

111109
return Logdown
112110
}

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "logdown",
3-
"version": "3.0.2",
3+
"version": "3.1.0",
44
"description": "Debug utility with markdown support that runs on browser and server",
55
"main": "src/node.js",
66
"browser": "dist/logdown.min.js",

0 commit comments

Comments
 (0)