Skip to content

Commit 0964567

Browse files
committed
Inline logger helpers for idiomatic usage
1 parent fda46d9 commit 0964567

File tree

200 files changed

+1118
-1083
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

200 files changed

+1118
-1083
lines changed

build-support/nuke-build/Build.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ partial class Build : NukeBuild
3737
readonly bool BuildEms = false;
3838

3939
[Parameter("Version")]
40-
readonly string ProjectVersion = "3.0.2";
40+
readonly string ProjectVersion = "3.1.0";
4141

4242
[Solution] readonly Solution Solution;
4343
[GitRepository] readonly GitRepository GitRepository;

src/Spring/Spring.Aop/Aop/Framework/Adapter/ThrowsAdviceInterceptor.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ private void MapAllExceptionHandlingMethods(object advice)
165165

166166
if(log.IsEnabled(LogLevel.Debug))
167167
{
168-
log.Debug("Found exception handler method: " + method);
168+
log.LogDebug("Found exception handler method: " + method);
169169
}
170170

171171
#endregion
@@ -266,7 +266,7 @@ private MethodInfo GetExceptionHandler(Exception exception)
266266

267267
if(log.IsEnabled(LogLevel.Debug))
268268
{
269-
log.Debug("Trying to find handler for exception of type [" + exception.GetType().Name + "].");
269+
log.LogDebug("Trying to find handler for exception of type [" + exception.GetType().Name + "].");
270270
}
271271

272272
#endregion

src/Spring/Spring.Aop/Aop/Framework/AutoProxy/AbstractAdvisorAutoProxyCreator.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ protected virtual List<IAdvisor> FindAdvisorsThatCanApply(List<IAdvisor> candida
185185
{
186186
if (logger.IsEnabled(LogLevel.Information))
187187
{
188-
logger.Info($"Candidate advisor [{candidate}] accepted for targetType [{targetType}]");
188+
logger.LogInformation($"Candidate advisor [{candidate}] accepted for targetType [{targetType}]");
189189
}
190190
eligibleAdvisors.Add(candidate);
191191
}
@@ -200,15 +200,15 @@ protected virtual List<IAdvisor> FindAdvisorsThatCanApply(List<IAdvisor> candida
200200
{
201201
if (logger.IsEnabled(LogLevel.Information))
202202
{
203-
logger.Info($"Candidate advisor [{candidate}] accepted for targetType [{targetType}]");
203+
logger.LogInformation($"Candidate advisor [{candidate}] accepted for targetType [{targetType}]");
204204
}
205205
eligibleAdvisors.Add(candidate);
206206
}
207207
else
208208
{
209209
if (logger.IsEnabled(LogLevel.Information))
210210
{
211-
logger.Info($"Candidate advisor [{candidate}] rejected for targetType [{targetType}]");
211+
logger.LogInformation($"Candidate advisor [{candidate}] rejected for targetType [{targetType}]");
212212
}
213213
}
214214
}

src/Spring/Spring.Aop/Aop/Framework/AutoProxy/AbstractAutoProxyCreator.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ public virtual object PostProcessAfterInitialization(object obj, string objectNa
238238
{
239239
if (logger.IsEnabled(LogLevel.Debug))
240240
{
241-
logger.Debug(string.Format("Did not attempt to autoproxy infrastructure type [{0}]", objectType));
241+
logger.LogDebug(string.Format("Did not attempt to autoproxy infrastructure type [{0}]", objectType));
242242
}
243243

244244
nonAdvisedObjects.Add(cacheKey);
@@ -249,7 +249,7 @@ public virtual object PostProcessAfterInitialization(object obj, string objectNa
249249
{
250250
if (logger.IsEnabled(LogLevel.Debug))
251251
{
252-
logger.Debug(string.Format("Skipping type [{0}]", objectType));
252+
logger.LogDebug(string.Format("Skipping type [{0}]", objectType));
253253
}
254254

255255
nonAdvisedObjects.Add(cacheKey);
@@ -390,7 +390,7 @@ protected virtual ITargetSource GetCustomTargetSource(Type objectType, string na
390390
// found a match
391391
if (logger.IsEnabled(LogLevel.Information))
392392
{
393-
logger.Info(string.Format("TargetSourceCreator [{0} found custom TargetSource for object with objectName '{1}'", tsc, name));
393+
logger.LogInformation(string.Format("TargetSourceCreator [{0} found custom TargetSource for object with objectName '{1}'", tsc, name));
394394
}
395395
return ts;
396396
}
@@ -514,7 +514,7 @@ protected virtual IList<IAdvisor> BuildAdvisors(string targetName, IList<object>
514514
{
515515
int nrOfCommonInterceptors = commonInterceptors != null ? commonInterceptors.Count : 0;
516516
int nrOfSpecificInterceptors = specificInterceptors != null ? specificInterceptors.Count : 0;
517-
logger.Info(string.Format("Creating implicit proxy for object '{0}' with {1} common interceptors and {2} specific interceptors", targetName, nrOfCommonInterceptors, nrOfSpecificInterceptors));
517+
logger.LogInformation(string.Format("Creating implicit proxy for object '{0}' with {1} common interceptors and {2} specific interceptors", targetName, nrOfCommonInterceptors, nrOfSpecificInterceptors));
518518
}
519519

520520

@@ -576,7 +576,7 @@ public object PostProcessBeforeInstantiation(Type objectType, string objectName)
576576
{
577577
if (logger.IsEnabled(LogLevel.Debug))
578578
{
579-
logger.Debug(string.Format("Did not attempt to autoproxy infrastructure type [{0}]", objectType));
579+
logger.LogDebug(string.Format("Did not attempt to autoproxy infrastructure type [{0}]", objectType));
580580
}
581581

582582
nonAdvisedObjects.Add(cacheKey);
@@ -587,7 +587,7 @@ public object PostProcessBeforeInstantiation(Type objectType, string objectName)
587587
{
588588
if (logger.IsEnabled(LogLevel.Debug))
589589
{
590-
logger.Debug(string.Format("Skipping type [{0}]", objectType));
590+
logger.LogDebug(string.Format("Skipping type [{0}]", objectType));
591591
}
592592

593593
nonAdvisedObjects.Add(cacheKey);

src/Spring/Spring.Aop/Aop/Framework/AutoProxy/ObjectFactoryAdvisorRetrievalHelper.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public virtual List<IAdvisor> FindAdvisorObjects(Type targetType, string targetN
9090
{
9191
if (_log.IsEnabled(LogLevel.Debug))
9292
{
93-
_log.Debug(string.Format("Ignoring currently created advisor '{0}': exception message = {1}",
93+
_log.LogDebug(string.Format("Ignoring currently created advisor '{0}': exception message = {1}",
9494
name, ex.Message));
9595
}
9696
continue;

src/Spring/Spring.Aop/Aop/Framework/AutoProxy/Target/AbstractPrototypeTargetSourceCreator.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ public ITargetSource GetTargetSource(Type objectType, string name, IObjectFactor
6363
if (!(factory is IObjectDefinitionRegistry))
6464
{
6565
if (logger.IsEnabled(LogLevel.Warning))
66-
logger.Warn("Cannot do autopooling with a IObjectFactory that doesn't implement IObjectDefinitionRegistry");
66+
logger.LogWarning("Cannot do autopooling with a IObjectFactory that doesn't implement IObjectDefinitionRegistry");
6767
return null;
6868
}
6969
IObjectDefinitionRegistry definitionRegistry = (IObjectDefinitionRegistry) factory;
7070
RootObjectDefinition definition = (RootObjectDefinition) definitionRegistry.GetObjectDefinition(name);
7171

7272
if (logger.IsEnabled(LogLevel.Information))
73-
logger.Info("Configuring AbstractPrototypeBasedTargetSource...");
73+
logger.LogInformation("Configuring AbstractPrototypeBasedTargetSource...");
7474

7575
// Infinite cycle will result if we don't use a different factory,
7676
// because a GetObject() call with this objectName will go through the autoproxy

src/Spring/Spring.Aop/Aop/Framework/ProxyFactoryObject.cs

+19-19
Original file line numberDiff line numberDiff line change
@@ -367,8 +367,8 @@ public virtual object GetObject()
367367

368368
if (targetName == null)
369369
{
370-
logger.Warn("Using non-singleton proxies with singleton targets is often undesirable. " +
371-
"Enable prototype proxies by setting the 'targetName' property.");
370+
logger.LogWarning("Using non-singleton proxies with singleton targets is often undesirable. " +
371+
"Enable prototype proxies by setting the 'targetName' property.");
372372
}
373373
return NewPrototypeInstance();
374374
}
@@ -442,7 +442,7 @@ private object NewPrototypeInstance()
442442

443443
if (logger.IsEnabled(LogLevel.Debug))
444444
{
445-
logger.Debug("Creating copy of prototype ProxyFactoryObject config: " + this);
445+
logger.LogDebug("Creating copy of prototype ProxyFactoryObject config: " + this);
446446
}
447447

448448
// The copy needs a fresh advisor chain, and a fresh TargetSource.
@@ -454,7 +454,7 @@ private object NewPrototypeInstance()
454454

455455
if (logger.IsEnabled(LogLevel.Debug))
456456
{
457-
logger.Debug("Using ProxyConfig: " + copy);
457+
logger.LogDebug("Using ProxyConfig: " + copy);
458458
}
459459

460460
object generatedProxy = copy.CreateAopProxy().GetProxy();
@@ -469,15 +469,15 @@ private void Initialize()
469469
{
470470
if (logger.IsEnabled(LogLevel.Debug))
471471
{
472-
logger.Debug(string.Format("Initialize: begin configure target, interceptors and introductions for {0}[{1}]", GetType().Name, GetHashCode()));
472+
logger.LogDebug(string.Format("Initialize: begin configure target, interceptors and introductions for {0}[{1}]", GetType().Name, GetHashCode()));
473473
}
474474

475475
InitializeAdvisorChain();
476476
InitializeIntroductionChain();
477477

478478
if (logger.IsEnabled(LogLevel.Debug))
479479
{
480-
logger.Debug(string.Format("Initialize: completed configuration for {0}[{1}]: {2}", GetType().Name, GetHashCode(), ToProxyConfigString()));
480+
logger.LogDebug(string.Format("Initialize: completed configuration for {0}[{1}]: {2}", GetType().Name, GetHashCode(), ToProxyConfigString()));
481481
}
482482
}
483483

@@ -523,7 +523,7 @@ private void InitializeAdvisorChain()
523523

524524
if (logger.IsEnabled(LogLevel.Debug))
525525
{
526-
logger.Debug("Adding global advisor '" + name + "'");
526+
logger.LogDebug("Adding global advisor '" + name + "'");
527527
}
528528

529529
AddGlobalAdvisor(lof, name.Substring(0, (name.Length - GlobalInterceptorSuffix.Length)));
@@ -532,7 +532,7 @@ private void InitializeAdvisorChain()
532532
{
533533
if (logger.IsEnabled(LogLevel.Debug))
534534
{
535-
logger.Debug("resolving advisor name " + "'" + name + "'");
535+
logger.LogDebug("resolving advisor name " + "'" + name + "'");
536536
}
537537

538538
// If we get here, we need to add a named interceptor.
@@ -558,15 +558,15 @@ private void AddAdvisorOnChainCreation(object advice, string name)
558558
{
559559
if (logger.IsEnabled(LogLevel.Debug))
560560
{
561-
logger.Debug(string.Format("Adding advisor list '{0}'", name));
561+
logger.LogDebug(string.Format("Adding advisor list '{0}'", name));
562562
}
563563

564564
IAdvisors advisors = (IAdvisors)advice;
565565
foreach (object element in advisors.Advisors)
566566
{
567567
if (logger.IsEnabled(LogLevel.Debug))
568568
{
569-
logger.Debug(string.Format("Adding advisor '{0}' of type {1}", name, element.GetType().FullName));
569+
logger.LogDebug(string.Format("Adding advisor '{0}' of type {1}", name, element.GetType().FullName));
570570
}
571571

572572
IAdvisor advisor = NamedObjectToAdvisor(element);
@@ -577,7 +577,7 @@ private void AddAdvisorOnChainCreation(object advice, string name)
577577
{
578578
if (logger.IsEnabled(LogLevel.Debug))
579579
{
580-
logger.Debug(string.Format("Adding advisor '{0}' of type {1}", name, advice.GetType().FullName));
580+
logger.LogDebug(string.Format("Adding advisor '{0}' of type {1}", name, advice.GetType().FullName));
581581
}
582582

583583
IAdvisor advisor = NamedObjectToAdvisor(advice);
@@ -679,7 +679,7 @@ private void InitializeIntroductionChain()
679679

680680
if (logger.IsEnabled(LogLevel.Debug))
681681
{
682-
logger.Debug("Adding introduction '" + name + "'");
682+
logger.LogDebug("Adding introduction '" + name + "'");
683683
}
684684

685685
if (name.EndsWith(GlobalInterceptorSuffix))
@@ -783,7 +783,7 @@ private void AddGlobalIntroduction(IListableObjectFactory objectFactory, string
783783
/// <param name="name">object name from which we obtained this object in our owning object factory</param>
784784
private void AddIntroductionOnChainCreation(object introduction, string name)
785785
{
786-
logger.Debug($"Adding introduction with name '{name}'");
786+
logger.LogDebug($"Adding introduction with name '{name}'");
787787
IIntroductionAdvisor advisor = NamedObjectToIntroduction(introduction);
788788
AddIntroduction(advisor);
789789
}
@@ -797,7 +797,7 @@ private ITargetSource FreshTargetSource()
797797
{
798798
if (logger.IsEnabled(LogLevel.Debug))
799799
{
800-
logger.Debug("Not Refreshing TargetSource: No target name specified");
800+
logger.LogDebug("Not Refreshing TargetSource: No target name specified");
801801
}
802802

803803
return TargetSource;
@@ -807,7 +807,7 @@ private ITargetSource FreshTargetSource()
807807

808808
if (logger.IsEnabled(LogLevel.Debug))
809809
{
810-
logger.Debug("Refreshing TargetSource with name '" + targetName + "'");
810+
logger.LogDebug("Refreshing TargetSource with name '" + targetName + "'");
811811
}
812812

813813
object target = objectFactory.GetObject(targetName);
@@ -830,7 +830,7 @@ private IList<IAdvisor> FreshAdvisorChain()
830830
PrototypePlaceholder pa = (PrototypePlaceholder)advisor;
831831
if (logger.IsEnabled(LogLevel.Debug))
832832
{
833-
logger.Debug(string.Format("Refreshing advisor '{0}'", pa.ObjectName));
833+
logger.LogDebug(string.Format("Refreshing advisor '{0}'", pa.ObjectName));
834834
}
835835

836836
AssertUtils.ArgumentNotNull(objectFactory, "ObjectFactory");
@@ -862,7 +862,7 @@ private IList<IIntroductionAdvisor> FreshIntroductionChain()
862862
PrototypePlaceholder pa = (PrototypePlaceholder)introduction;
863863
if (logger.IsEnabled(LogLevel.Debug))
864864
{
865-
logger.Debug(string.Format("Refreshing introduction '{0}'", pa.ObjectName));
865+
logger.LogDebug(string.Format("Refreshing introduction '{0}'", pa.ObjectName));
866866
}
867867

868868
AssertUtils.ArgumentNotNull(objectFactory, "ObjectFactory");
@@ -934,7 +934,7 @@ private IIntroductionAdvisor NamedObjectToIntroduction(object introduction)
934934
/// </remarks>
935935
protected override void InterfacesChanged()
936936
{
937-
logger.Info("Implemented interfaces have changed; reseting singleton instance");
937+
logger.LogInformation("Implemented interfaces have changed; reseting singleton instance");
938938
singletonInstance = null;
939939
base.InterfacesChanged();
940940
}
@@ -967,7 +967,7 @@ private void CheckInterceptorNames()
967967
targetName = finalName;
968968
if (logger.IsEnabled(LogLevel.Debug))
969969
{
970-
logger.Debug(string.Format("Object with name '{0}' concluding interceptor chain is not an advisor class: treating it as a target or TargetSource", finalName));
970+
logger.LogDebug(string.Format("Object with name '{0}' concluding interceptor chain is not an advisor class: treating it as a target or TargetSource", finalName));
971971
}
972972
String[] newNames = new String[interceptorNames.Length - 1];
973973
Array.Copy(interceptorNames, 0, newNames, 0, newNames.Length);

src/Spring/Spring.Aop/Aop/Support/SdkRegularExpressionMethodPointcut.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ protected override bool Matches(string pattern, int patternIndex)
160160

161161
if (_logger.IsEnabled(LogLevel.Debug))
162162
{
163-
_logger.Debug("Candidate is: '" + pattern + "'; pattern is '" +
164-
_compiledPatterns[patternIndex].ToString() + "'; matched=" + matched);
163+
_logger.LogDebug("Candidate is: '" + pattern + "'; pattern is '" +
164+
_compiledPatterns[patternIndex].ToString() + "'; matched=" + matched);
165165
}
166166

167167
return matched;

src/Spring/Spring.Aop/Aop/Target/AbstractPrototypeTargetSource.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,9 @@ public virtual IObjectFactory ObjectFactory
138138

139139
if (logger.IsEnabled(LogLevel.Debug))
140140
{
141-
logger.Debug(string.Format(
142-
"Getting object with name '{0}' to determine class.",
143-
TargetObjectName));
141+
logger.LogDebug(string.Format(
142+
"Getting object with name '{0}' to determine class.",
143+
TargetObjectName));
144144
}
145145

146146
#endregion
@@ -162,9 +162,9 @@ protected virtual object NewPrototypeInstance()
162162

163163
if (logger.IsEnabled(LogLevel.Debug))
164164
{
165-
logger.Debug(string.Format(
166-
"Creating new target from object '{0}'.",
167-
TargetObjectName));
165+
logger.LogDebug(string.Format(
166+
"Creating new target from object '{0}'.",
167+
TargetObjectName));
168168
}
169169

170170
#endregion

src/Spring/Spring.Aop/Aop/Target/SimplePoolTargetSource.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ protected override void CreatePool(IObjectFactory factory)
6969

7070
if(logger.IsEnabled(LogLevel.Debug))
7171
{
72-
logger.Debug("Creating object pool.");
72+
logger.LogDebug("Creating object pool.");
7373
}
7474

7575
#endregion
@@ -138,7 +138,7 @@ public override void Dispose()
138138

139139
if(logger.IsEnabled(LogLevel.Debug))
140140
{
141-
logger.Debug("Closing pool...");
141+
logger.LogDebug("Closing pool...");
142142
}
143143

144144
#endregion

src/Spring/Spring.Aop/Aop/Target/ThreadLocalTargetSource.cs

+12-11
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,10 @@ public override Object GetTarget()
148148

149149
if (logger.IsEnabled(LogLevel.Debug))
150150
{
151-
logger.Debug(string.Format(
152-
"No target for apartment prototype '{0}' " +
153-
"found in thread: creating one and binding it to thread '#{1}'",
154-
TargetObjectName, Thread.CurrentThread.GetHashCode()));
151+
logger.LogDebug(string.Format(
152+
"No target for apartment prototype '{0}' " +
153+
"found in thread: creating one and binding it to thread '#{1}'",
154+
TargetObjectName, Thread.CurrentThread.GetHashCode()));
155155
}
156156

157157
#endregion
@@ -187,7 +187,7 @@ public void Dispose()
187187

188188
if (logger.IsEnabled(LogLevel.Debug))
189189
{
190-
logger.Debug("Destroying ThreadLocal bindings");
190+
logger.LogDebug("Destroying ThreadLocal bindings");
191191
}
192192

193193
#endregion
@@ -205,12 +205,13 @@ public void Dispose()
205205
#region Instrumentation
206206

207207
if (logger.IsEnabled(LogLevel.Warning))
208-
{
209-
logger.Warn(string.Format(
210-
"Thread-bound target of class '{0}' " +
211-
"threw exception from it's IDisposable.Dispose() method.",
212-
target.GetType()), ex);
213-
}
208+
{
209+
string message = string.Format(
210+
"Thread-bound target of class '{0}' " +
211+
"threw exception from it's IDisposable.Dispose() method.",
212+
target.GetType());
213+
logger.LogWarning(ex, message);
214+
}
214215

215216
#endregion
216217
}

0 commit comments

Comments
 (0)