@@ -80,7 +80,7 @@ private[airframe] class AirframeSession(parent: Option[AirframeSession],
80
80
}
81
81
82
82
override def newSharedChildSession (d : Design ): Session = {
83
- trace(s " Creating a new shared child session with ${d}" )
83
+ trace(s " [ ${name} ] Creating a new shared child session with ${d}" )
84
84
val childSession = new AirframeSession (
85
85
parent = Some (this ),
86
86
sessionName, // Should we add suffixes for child sessions?
@@ -103,7 +103,7 @@ private[airframe] class AirframeSession(parent: Option[AirframeSession],
103
103
)
104
104
// LifeCycleManager needs to know about the session
105
105
l.setSession(childSession)
106
- trace(s " Creating a new child session ${childSession.name} with ${d}" )
106
+ trace(s " [ ${name} ] Creating a new child session ${childSession.name} with ${d}" )
107
107
childSession
108
108
}
109
109
@@ -112,7 +112,7 @@ private[airframe] class AirframeSession(parent: Option[AirframeSession],
112
112
debug(s " [ ${name}] Initializing. Stage: ${stage}" )
113
113
val production = stage == Stage .PRODUCTION
114
114
if (production) {
115
- debug(s " Eagerly initializing singletons in production mode " )
115
+ debug(s " [ ${name} ] Eagerly initializing singletons in production mode" )
116
116
}
117
117
design.binding.collect {
118
118
case s @ SingletonBinding (from, to, eager) if production || eager =>
@@ -124,21 +124,21 @@ private[airframe] class AirframeSession(parent: Option[AirframeSession],
124
124
}
125
125
126
126
private [airframe] def get [A ](surface : Surface ): A = {
127
- debug(s " Get dependency [ ${surface}] " )
127
+ debug(s " [ ${name} ] Get dependency [ ${surface}] " )
128
128
getInstance(surface, this , create = false , List .empty).asInstanceOf [A ]
129
129
}
130
130
131
131
private [airframe] def getOrElse [A ](surface : Surface , objectFactory : => A ): A = {
132
- debug(s " Get dependency [ ${surface}] (or create with factory) " )
132
+ debug(s " [ ${name} ] Get dependency [ ${surface}] (or create with factory) " )
133
133
getInstance(surface, this , create = false , List .empty, Some (() => objectFactory)).asInstanceOf [A ]
134
134
}
135
135
136
136
private [airframe] def createNewInstanceOf [A ](surface : Surface ): A = {
137
- debug(s " Create dependency [ ${surface}] " )
137
+ debug(s " [ ${name} ] Create dependency [ ${surface}] " )
138
138
getInstance(surface, this , create = true , List .empty).asInstanceOf [A ]
139
139
}
140
140
private [airframe] def createNewInstanceOf [A ](surface : Surface , factory : => A ): A = {
141
- debug(s " Create dependency [ ${surface}] (with factory) " )
141
+ debug(s " [ ${name} ] Create dependency [ ${surface}] (with factory) " )
142
142
getInstance(surface, this , create = true , List .empty, Some (() => factory)).asInstanceOf [A ]
143
143
}
144
144
@@ -147,7 +147,7 @@ private[airframe] class AirframeSession(parent: Option[AirframeSession],
147
147
* The other hooks (e.g., onStart, onShutdown) will be called in a separate step after the object is injected.
148
148
*/
149
149
private def registerInjectee (t : Surface , injectee : Any ): AnyRef = {
150
- debug(s " Inject [ ${t}]: ${injectee}" )
150
+ debug(s " [ ${name} ] Inject [ ${t}]: ${injectee}" )
151
151
observedTypes.getOrElseUpdate(t, System .currentTimeMillis())
152
152
Try (lifeCycleManager.onInit(t, injectee.asInstanceOf [AnyRef ])).recover {
153
153
case e : Throwable =>
@@ -176,7 +176,7 @@ private[airframe] class AirframeSession(parent: Option[AirframeSession],
176
176
create : Boolean , // true for factory binding
177
177
seen : List [Surface ],
178
178
defaultValue : Option [() => Any ] = None ): AnyRef = {
179
- trace(s " Search bindings for ${t}, dependencies:[ ${seen.mkString(" <- " )}] " )
179
+ trace(s " [ ${name} ] Search bindings for ${t}, dependencies:[ ${seen.mkString(" <- " )}] " )
180
180
if (seen.contains(t)) {
181
181
error(s " Found cyclic dependencies: ${seen}" )
182
182
throw new CYCLIC_DEPENDENCY (seen.toSet)
@@ -188,7 +188,7 @@ private[airframe] class AirframeSession(parent: Option[AirframeSession],
188
188
bindingTable.get(t) match {
189
189
case None =>
190
190
// If no binding is found in the current, traverse to the parent.
191
- trace(s " Search parent for ${t}" )
191
+ trace(s " [ ${name} ] Search parent for ${t}" )
192
192
parent.flatMap { p =>
193
193
p.findOwnerSessionOf(t).map { owner =>
194
194
// Use the parent session only when some binding is found in the parent
@@ -199,21 +199,21 @@ private[airframe] class AirframeSession(parent: Option[AirframeSession],
199
199
val result =
200
200
b match {
201
201
case ClassBinding (from, to) =>
202
- trace(s " Found a class binding from ${from} to ${to}" )
202
+ trace(s " [ ${name} ] Found a class binding from ${from} to ${to}" )
203
203
registerInjectee(from, contextSession.getInstance(to, contextSession, create, t :: seen))
204
204
case sb @ SingletonBinding (from, to, eager) if from != to =>
205
- trace(s " Found a singleton binding: ${from} => ${to}" )
205
+ trace(s " [ ${name} ] Found a singleton binding: ${from} => ${to}" )
206
206
singletonHolder.getOrElseUpdate(
207
207
from,
208
208
registerInjectee(from,
209
209
contextSession.getInstance(to, contextSession, create, t :: seen, defaultValue)))
210
210
case sb @ SingletonBinding (from, to, eager) if from == to =>
211
- trace(s " Found a singleton binding: ${from}" )
211
+ trace(s " [ ${name} ] Found a singleton binding: ${from}" )
212
212
singletonHolder.getOrElseUpdate(
213
213
from,
214
214
registerInjectee(from, contextSession.buildInstance(to, contextSession, seen, defaultValue)))
215
215
case p @ ProviderBinding (factory, provideSingleton, eager) =>
216
- trace(s " Found a provider for ${p.from}: ${p}" )
216
+ trace(s " [ ${name} ] Found a provider for ${p.from}: ${p}" )
217
217
def buildWithProvider : Any = {
218
218
val dependencies = for (d <- factory.dependencyTypes) yield {
219
219
contextSession.getInstance(d, contextSession, false , t :: seen)
@@ -231,7 +231,7 @@ private[airframe] class AirframeSession(parent: Option[AirframeSession],
231
231
232
232
val result =
233
233
obj.getOrElse {
234
- trace(s " No binding is found for ${t}. Building the instance. create = ${create}" )
234
+ trace(s " [ ${name} ] No binding is found for ${t}. Building the instance. create = ${create}" )
235
235
if (create) {
236
236
// Create a new instance for bindFactory[X] or building X using its default value
237
237
registerInjectee(t, contextSession.buildInstance(t, contextSession, seen, defaultValue))
@@ -252,18 +252,18 @@ private[airframe] class AirframeSession(parent: Option[AirframeSession],
252
252
defaultValue : Option [() => Any ] = None ): Any = {
253
253
traitFactoryCache
254
254
.get(t).map { f =>
255
- trace(s " Using a pre-registered trait factory for ${t}" )
255
+ trace(s " [ ${name} ] Using a pre-registered trait factory for ${t}" )
256
256
f(this )
257
257
}
258
258
.orElse {
259
259
// Use the provided object factory if exists
260
260
defaultValue.map { f =>
261
- trace(s " Using the default value for ${t}" )
261
+ trace(s " [ ${name} ] Using the default value for ${t}" )
262
262
f()
263
263
}
264
264
}
265
265
.getOrElse {
266
- trace(s " No binding is found for ${t}" )
266
+ trace(s " [ ${name} ] No binding is found for ${t}" )
267
267
buildInstance(t, contextSession, t :: seen)
268
268
}
269
269
}
@@ -272,7 +272,7 @@ private[airframe] class AirframeSession(parent: Option[AirframeSession],
272
272
* Create a new instance of the surface
273
273
*/
274
274
private def buildInstance (surface : Surface , contextSession : AirframeSession , seen : List [Surface ]): Any = {
275
- trace(s " buildInstance ${surface}, dependencies:[ ${seen.mkString(" <- " )}] " )
275
+ trace(s " [ ${name} ] buildInstance ${surface}, dependencies:[ ${seen.mkString(" <- " )}] " )
276
276
if (surface.isPrimitive) {
277
277
// Cannot build Primitive types
278
278
throw MISSING_DEPENDENCY (seen)
@@ -294,12 +294,12 @@ private[airframe] class AirframeSession(parent: Option[AirframeSession],
294
294
case None =>
295
295
val obj = traitFactoryCache.get(surface) match {
296
296
case Some (factory) =>
297
- trace(s " Using pre-compiled factory for ${surface}" )
297
+ trace(s " [ ${name} ] Using pre-compiled factory for ${surface}" )
298
298
factory.asInstanceOf [Session => Any ](this )
299
299
case None =>
300
300
// buildWithReflection(t)
301
301
warn(
302
- s " No binding nor the default constructor for ${surface} is found. " +
302
+ s " [ ${name} ] No binding nor the default constructor for ${surface} is found. " +
303
303
s " Add bind[ ${surface}].toXXX to your design or dependencies:[ ${seen.mkString(" <- " )}] " )
304
304
throw MISSING_DEPENDENCY (seen)
305
305
}
0 commit comments