Well, therefore, after reading danben's answer to this post , I think I am convinced of the need to write such code, in many cases. My managers agree too.
if (log.IsDebugEnabled) log.Debug("ZDRCreatorConfig("+rootelem.ToString()+")"); if (log.IsInfoEnabled) log.Info("Reading Configuration . . .");
The problem with this is the bug due to which I see all these if statements posted everywhere, just to make a simple log statement.
My question is, how can we reorganize this into a class without repeating the performance problem when evaluating the arguments to the log method?
Just putting it in a class, as the static method does not help, because when you pass an Object message, it still needs to evaluate the argument:
public class LogHelper { public static Info(ILog log, Object message) { if(log.IsInfoEnabled) { log.Info(message); } } }
C # does not seem to support forcing the method to be inline, so a solution is not available. MACRO is not supported in C #. What we can do?!?!
UPDATE: Thanks for the answers, I have not forgotten about this; it's just the lowest priorty on my list right now. I will get to him and give the answer as soon as I catch a little. Thanks.
Other UPDATE:
okay ... I still don't look at this very close, and you both deserve the right answer; but I awarded Tanzelax for the answer, because I agree, I think they will be automatically included. The link that he posted really helps to convince me that I should not worry too much about it right now, which is also good. I will continue to look at these lambda things later. Thanks for the help!