mirror of
https://github.com/mbierlee/poodinis.git
synced 2024-11-15 04:04:01 +01:00
Add debug specifier to reduce verbosity of debug output
This commit is contained in:
parent
77cc636e7f
commit
7a628c32c4
11
dub.json
11
dub.json
|
@ -19,6 +19,17 @@
|
|||
"dflags-dmd": [
|
||||
"-main"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "unittestVerbose",
|
||||
"targetType": "executable",
|
||||
"debugVersions": ["poodinisVerbose"],
|
||||
"sourcePaths": [
|
||||
"test"
|
||||
],
|
||||
"dflags-dmd": [
|
||||
"-main"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -27,7 +27,7 @@ alias Autowired = Autowire;
|
|||
public void autowire(Type)(DependencyContainer container, Type instance) {
|
||||
// For the love of god, refactor this!
|
||||
|
||||
debug {
|
||||
debug(poodinisVerbose) {
|
||||
auto instanceType = typeid(Type);
|
||||
auto instanceAddress = &instance;
|
||||
writeln(format("DEBUG: Autowiring members of [%s@%s]", instanceType, instanceAddress));
|
||||
|
@ -40,7 +40,8 @@ public void autowire(Type)(DependencyContainer container, Type instance) {
|
|||
if (__traits(getMember, instance, member) is null) {
|
||||
alias memberReference = TypeTuple!(__traits(getMember, instance, member));
|
||||
alias MemberType = typeof(memberReference)[0];
|
||||
debug {
|
||||
|
||||
debug(poodinisVerbose) {
|
||||
string qualifiedInstanceTypeString = typeid(MemberType).toString;
|
||||
}
|
||||
|
||||
|
@ -48,7 +49,7 @@ public void autowire(Type)(DependencyContainer container, Type instance) {
|
|||
static if (is(autowireAttribute == Autowire!T, T) && !is(autowireAttribute.qualifier == UseMemberType)) {
|
||||
alias QualifierType = typeof(autowireAttribute.qualifier);
|
||||
qualifiedInstance = container.resolve!(typeof(memberReference), QualifierType);
|
||||
debug {
|
||||
debug(poodinisVerbose) {
|
||||
qualifiedInstanceTypeString = typeid(QualifierType).toString;
|
||||
}
|
||||
} else {
|
||||
|
@ -57,7 +58,7 @@ public void autowire(Type)(DependencyContainer container, Type instance) {
|
|||
|
||||
__traits(getMember, instance, member) = qualifiedInstance;
|
||||
|
||||
debug {
|
||||
debug(poodinisVerbose) {
|
||||
auto qualifiedInstanceAddress = &qualifiedInstance;
|
||||
writeln(format("DEBUG: Autowired instance [%s@%s] to [%s@%s].%s", qualifiedInstanceTypeString, qualifiedInstanceAddress, instanceType, instanceAddress, member));
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ class DependencyContainer {
|
|||
TypeInfo registeredType = typeid(InterfaceType);
|
||||
TypeInfo_Class concreteType = typeid(ConcreteType);
|
||||
|
||||
debug {
|
||||
debug(poodinisVerbose) {
|
||||
writeln(format("DEBUG: Register type %s (as %s)", concreteType.toString(), registeredType.toString()));
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ class DependencyContainer {
|
|||
TypeInfo resolveType = typeid(RegistrationType);
|
||||
TypeInfo qualifierType = typeid(QualifierType);
|
||||
|
||||
debug {
|
||||
debug(poodinisVerbose) {
|
||||
writeln("DEBUG: Resolving type " ~ resolveType.toString() ~ " with qualifier " ~ qualifierType.toString());
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ interface CreationScope {
|
|||
|
||||
class NullScope : CreationScope {
|
||||
public Object getInstance() {
|
||||
debug {
|
||||
debug(poodinisVerbose) {
|
||||
writeln("DEBUG: No instance created (NullScope)");
|
||||
}
|
||||
return null;
|
||||
|
@ -60,12 +60,12 @@ class SingleInstanceScope : CreationScope {
|
|||
|
||||
public Object getInstance() {
|
||||
if (instance is null) {
|
||||
debug {
|
||||
debug(poodinisVerbose) {
|
||||
writeln(format("DEBUG: Creating new instance of type %s (SingleInstanceScope)", instantiatableType.toString()));
|
||||
}
|
||||
instance = instantiatableType.create();
|
||||
} else {
|
||||
debug {
|
||||
debug(poodinisVerbose) {
|
||||
writeln(format("DEBUG: Existing instance returned of type %s (SingleInstanceScope)", instantiatableType.toString()));
|
||||
}
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ class NewInstanceScope : CreationScope {
|
|||
}
|
||||
|
||||
public Object getInstance() {
|
||||
debug {
|
||||
debug(poodinisVerbose) {
|
||||
writeln(format("DEBUG: Creating new instance of type %s (SingleInstanceScope)", instantiatableType.toString()));
|
||||
}
|
||||
return instantiatableType.create();
|
||||
|
@ -108,7 +108,7 @@ class ExistingInstanceScope : CreationScope {
|
|||
}
|
||||
|
||||
public Object getInstance() {
|
||||
debug {
|
||||
debug(poodinisVerbose) {
|
||||
writeln("DEBUG: Existing instance returned (ExistingInstanceScope)");
|
||||
}
|
||||
return instance;
|
||||
|
|
Loading…
Reference in a new issue