use .storeName during tracing (#560)

This commit is contained in:
Yoshua Wuyts
2017-10-03 12:34:36 -04:00
committed by GitHub
parent db07336845
commit 92372b9bff
2 changed files with 8 additions and 2 deletions
+5 -1
View File
@@ -414,7 +414,11 @@ Initialize a new `choo` instance. `opts` can also contain the following values:
Call a function and pass it a `state` and `emitter`. `emitter` is an instance Call a function and pass it a `state` and `emitter`. `emitter` is an instance
of [nanobus](https://github.com/choojs/nanobus/). You can listen to of [nanobus](https://github.com/choojs/nanobus/). You can listen to
messages by calling `emitter.on()` and emit messages by calling messages by calling `emitter.on()` and emit messages by calling
`emitter.emit()`. `emitter.emit()`. Callbacks passed to `app.use()` are commonly referred to as
`'stores'`.
If the callback has a `.storeName` property on it, it will be used to identify
the callback during tracing.
See [#events](#events) for an overview of all events. See [#events](#events) for an overview of all events.
+3 -1
View File
@@ -77,7 +77,9 @@ Choo.prototype.route = function (route, handler) {
Choo.prototype.use = function (cb) { Choo.prototype.use = function (cb) {
assert.equal(typeof cb, 'function', 'choo.use: cb should be type function') assert.equal(typeof cb, 'function', 'choo.use: cb should be type function')
var endTiming = nanotiming('choo.use') var msg = 'choo.use'
msg = cb.storeName ? msg + '(' + cb.storeName + ')' : msg
var endTiming = nanotiming(msg)
cb(this.state, this.emitter, this) cb(this.state, this.emitter, this)
endTiming() endTiming()
} }