Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I beg to differ with opinions raised here about the usefulness of logging, and about the problems of using a fixed template for each function.</p> <p>Base on the Jerry Dennany's article <a href="http://www.codeproject.com/Articles/3737/TraceListeners-and-Reflection" rel="nofollow">TraceListeners and Reflection</a>, I've extended <a href="http://www.theobjectguy.com/" rel="nofollow">the Object Guy's logging framework</a> to produce an indented trace of my code. This can further be processed by logging tools but I don't bother - It's sometimes very constructive just to scan the results.</p> <p>Of course, using aspect programming is the correct thing to do, but I never got to learning it. so I'm uisng the following snippet inside each and every of my methods to log, to verify each method's arguments, and to catch exceptions (which, by default, are re-thrown)</p> <pre><code>&lt;CodeSnippet Format="1.0.0"&gt; &lt;Header&gt; &lt;Title&gt;Canonic&lt;/Title&gt; &lt;SnippetTypes&gt; &lt;SnippetType&gt;Expansion&lt;/SnippetType&gt; &lt;/SnippetTypes&gt; &lt;/Header&gt; &lt;Snippet&gt; &lt;Declarations&gt; &lt;Literal&gt; &lt;ID&gt;ClassName&lt;/ID&gt; &lt;ToolTip&gt;Replace with the name of the class.&lt;/ToolTip&gt; &lt;Default&gt;ClassName&lt;/Default&gt; &lt;/Literal&gt; &lt;Literal&gt; &lt;ID&gt;MethodName&lt;/ID&gt; &lt;ToolTip&gt;Replace with the name of the method.&lt;/ToolTip&gt; &lt;Default&gt;MethodName&lt;/Default&gt; &lt;/Literal&gt; &lt;Literal&gt; &lt;ID&gt;FirstArgName&lt;/ID&gt; &lt;ToolTip&gt;Replace with the name of the first argument.&lt;/ToolTip&gt; &lt;Default&gt;FirstArgName&lt;/Default&gt; &lt;/Literal&gt; &lt;Literal&gt; &lt;ID&gt;SecondArgName&lt;/ID&gt; &lt;ToolTip&gt;Replace with the name of the second argument.&lt;/ToolTip&gt; &lt;Default&gt;SecondArgName&lt;/Default&gt; &lt;/Literal&gt; &lt;Literal&gt; &lt;ID&gt;ResultName&lt;/ID&gt; &lt;ToolTip&gt;Replace with the name of the result.&lt;/ToolTip&gt; &lt;Default&gt;ResultName&lt;/Default&gt; &lt;/Literal&gt; &lt;/Declarations&gt; &lt;Code Language="CSharp"&gt; &lt;![CDATA[ Logger.LogMethod("$FirstArgName$", $FirstArgName$,"$SecondArgName$", $SecondArgName$); try { Validator.Verify($FirstArgName$, $SecondArgName$); //VerifyFields(); Logger.LogReturn($ResultName$); return $ResultName$; } #region Exception catch (Exception exp) { Logger.LogException("$ClassName$.$MethodName$", exp); throw; } #endregion Exception ]]&gt; &lt;/Code&gt; &lt;/Snippet&gt; </code></pre> <p></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload