You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Take a look at the code I borrowed from your documentation below
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
// flat strings...
if (this.Log.IsInfoEnabled)
this.Log.Info("I've been navigated to.");
// formatting...
if (this.Log.IsDebugEnabled)
this.Log.Debug("I can also format {0}.", "strings");
// errors...
try
{
this.DoMagic();
}
catch(Exception ex)
{
if (this.Log.IsWarnEnabled)
this.Log.Warn("You can also pass in exceptions.", ex);
}
}
The code above pollutes otherwise nice and clean code with lots of logging calls. It gets even worse if you add to it exception handling, instrumentation calls (i.e. to measure the execution time of each method by using StopWatch, etc) and the method that should have 1 or 2 lines of code became a tangled complex spaghetti ball.
This violates KISS, SRP, 10/100 and bunch of other principles. The method above should really look like this:
It would be nice if MetroLog could be used as AOP (Aspect Oriented Programming) library, have you ever thought about that? That way, the method above could be used something like this:
I like MetroLog idea but I have 2 problems.
Take a look at the code I borrowed from your documentation below
The code above pollutes otherwise nice and clean code with lots of logging calls. It gets even worse if you add to it exception handling, instrumentation calls (i.e. to measure the execution time of each method by using StopWatch, etc) and the method that should have 1 or 2 lines of code became a tangled complex spaghetti ball.
This violates KISS, SRP, 10/100 and bunch of other principles. The method above should really look like this:
It would be nice if MetroLog could be used as AOP (Aspect Oriented Programming) library, have you ever thought about that? That way, the method above could be used something like this:
Where all the logging statements could be moved into a new class LogAspect.
The text was updated successfully, but these errors were encountered: