@@ -105,7 +105,11 @@ class Lifecycle extends EventEmitter {
105105 }
106106
107107 registerBeforeStart ( scope ) {
108- this [ REGISTER_READY_CALLBACK ] ( scope , this . loadReady , 'Before Start' ) ;
108+ this [ REGISTER_READY_CALLBACK ] ( {
109+ scope,
110+ ready : this . loadReady ,
111+ timingKeyPrefix : 'Before Start' ,
112+ } ) ;
109113 }
110114
111115 registerBeforeClose ( fn ) {
@@ -151,7 +155,12 @@ class Lifecycle extends EventEmitter {
151155 for ( const boot of this [ BOOTS ] ) {
152156 const didLoad = boot . didLoad && boot . didLoad . bind ( boot ) ;
153157 if ( didLoad ) {
154- this [ REGISTER_READY_CALLBACK ] ( didLoad , this . loadReady , 'Did Load' ) ;
158+ this [ REGISTER_READY_CALLBACK ] ( {
159+ scope : didLoad ,
160+ ready : this . loadReady ,
161+ timingKeyPrefix : 'Did Load' ,
162+ scopeFullName : boot . fullPath + ':didLoad' ,
163+ } ) ;
155164 }
156165 }
157166 }
@@ -162,7 +171,12 @@ class Lifecycle extends EventEmitter {
162171 for ( const boot of this [ BOOTS ] ) {
163172 const willReady = boot . willReady && boot . willReady . bind ( boot ) ;
164173 if ( willReady ) {
165- this [ REGISTER_READY_CALLBACK ] ( willReady , this . bootReady , 'Will Ready' ) ;
174+ this [ REGISTER_READY_CALLBACK ] ( {
175+ scope : willReady ,
176+ ready : this . bootReady ,
177+ timingKeyPrefix : 'Will Ready' ,
178+ scopeFullName : boot . fullPath + ':willReady' ,
179+ } ) ;
166180 }
167181 }
168182 }
@@ -230,13 +244,13 @@ class Lifecycle extends EventEmitter {
230244 }
231245 }
232246
233- [ REGISTER_READY_CALLBACK ] ( scope , ready , timingKeyPrefix ) {
247+ [ REGISTER_READY_CALLBACK ] ( { scope, ready, timingKeyPrefix, scopeFullName } ) {
234248 if ( ! is . function ( scope ) ) {
235249 throw new Error ( 'boot only support function' ) ;
236250 }
237251
238- // get filename from stack
239- const name = utils . getCalleeFromStack ( true , 4 ) ;
252+ // get filename from stack if scopeFullName is undefined
253+ const name = scopeFullName || utils . getCalleeFromStack ( true , 4 ) ;
240254 const timingkey = `${ timingKeyPrefix } in ` + utils . getResolvedFilename ( name , this . app . baseDir ) ;
241255
242256 this . timing . start ( timingkey ) ;
0 commit comments