home
products
contribute
download
documentation
forum
Home
Forums
New posts
Search forums
What's new
New posts
All posts
Latest activity
Members
Registered members
Current visitors
Donate
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Search titles only
By:
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
MediaPortal 1
Development
Improvement Suggestions
Why no code guard when logging?
Contact us
RSS
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="spiderwheels" data-source="post: 594487" data-attributes="member: 99116"><p>String literals are not expensive to construct. There is no construction as they are already in there in the assembly. </p><p></p><p>As you say, this:</p><p></p><p><span style="font-family: 'Courier New'">Log.Debug(string.Format("Some message: {0}",aString));</span></p><p></p><p>is expensive as the string.Format is called regardless of the log level.</p><p></p><p>In this instance the line should use the built in formatting methods of the Log class:</p><p></p><p><span style="font-family: 'Courier New'">Log.DebugFormat("Some message: {0}",aString);</span></p><p></p><p>Now the parameters are passed to the DebugFormat method and formatting only takes place if Debug is enabled.</p></blockquote><p></p>
[QUOTE="spiderwheels, post: 594487, member: 99116"] String literals are not expensive to construct. There is no construction as they are already in there in the assembly. As you say, this: [FONT="Courier New"]Log.Debug(string.Format("Some message: {0}",aString));[/FONT] is expensive as the string.Format is called regardless of the log level. In this instance the line should use the built in formatting methods of the Log class: [FONT="Courier New"]Log.DebugFormat("Some message: {0}",aString);[/FONT] Now the parameters are passed to the DebugFormat method and formatting only takes place if Debug is enabled. [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
MediaPortal 1
Development
Improvement Suggestions
Why no code guard when logging?
Contact us
RSS
Top
Bottom