Created
February 2, 2015 17:20
-
-
Save dmarlow/a7f65342d55630dcde2c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sw = Stopwatch.StartNew(); | |
var msg = new StringBuilder(); | |
bool error = false; | |
try | |
{ | |
msg.AppendFormat("Doing something with xyz {0}", blah); | |
if (!string.IsNullOrEmpty(value)) | |
{ | |
// do something here | |
msg.AppendFormat(" {0} --> {1}.", something, value); | |
} | |
else | |
{ | |
msg.Append(" null str."); | |
} | |
if (something) | |
{ | |
msg.Append(" blah."); | |
// do more stuff | |
} | |
return exValue; | |
} | |
catch (Exception e) | |
{ | |
// Either throw or append and set error = true. | |
} | |
finally | |
{ | |
sw.Stop(); | |
if (error) | |
{ | |
Log.ErrorFormat("{0} {1} ms", msg, sw.ElapsedMilliseconds); | |
} | |
else | |
{ | |
Log.DebugFormat("{0} {1} ms", msg, sw.ElapsedMilliseconds); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment