log setting to compile logging completely out of code?

43 views
Skip to first unread message

Morgan Jones

unread,
Jun 24, 2012, 9:56:07 AM6/24/12
to cocoalu...@googlegroups.com
I reviewed the source, but wanted to verify...
There doesn't appear to be a setting that would allow me to completely compile out some or all of the logs if desired?
True?

MDJ

Neil Tiffin

unread,
Jun 25, 2012, 10:22:15 AM6/25/12
to cocoalu...@googlegroups.com
I think that is the whole point of CocoaLumberjack. If you set the logging level to errors only, then only errors will be logged all other levels ignored. I would expect that you would want to always log errors, no?

But then again you might try setting ddLogLevel = LOG_LEVEL_OFF. Have not tried that.

Neil

Robbie Hanson

unread,
Jun 25, 2012, 3:35:22 PM6/25/12
to cocoalu...@googlegroups.com
When you compile with optimizations enabled (as is the case for release builds), disabled log statements are completely stripped from your build.

That is, if you have a verbose log statement, and your log level set to warnings, that verbose log statement will not incur any cost at runtime. This is because the DDLogVerbose macro is essentially turned into this:

if (ddLogLevel & LOG_FLAG_VERBOSE) { ... }

Since ddLogLevel is const, and the flag is also constant, the compiler will check the if statement, and strip it if false.

-Robbie Hanson
Sent from my iPhone
--
You received this message because you are subscribed to the Google Groups "CocoaLumberjack" group.
To view this discussion on the web visit https://groups.google.com/d/msg/cocoalumberjack/-/mqoMPvF6gisJ.
To post to this group, send email to cocoalu...@googlegroups.com.
To unsubscribe from this group, send email to cocoalumberja...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cocoalumberjack?hl=en.

Morgan Jones

unread,
Jun 25, 2012, 9:26:29 PM6/25/12
to cocoalu...@googlegroups.com
Perfect that was exactly what I was looking for!  Thanks.  MDJ


On Monday, June 25, 2012 3:35:22 PM UTC-4, Robbie Hanson wrote:
When you compile with optimizations enabled (as is the case for release builds), disabled log statements are completely stripped from your build.

That is, if you have a verbose log statement, and your log level set to warnings, that verbose log statement will not incur any cost at runtime. This is because the DDLogVerbose macro is essentially turned into this:

if (ddLogLevel & LOG_FLAG_VERBOSE) { ... }

Since ddLogLevel is const, and the flag is also constant, the compiler will check the if statement, and strip it if false.

-Robbie Hanson
Sent from my iPhone

On Jun 24, 2012, at 6:56 AM, Morgan Jones <mor...@gmail.com> wrote:

I reviewed the source, but wanted to verify...
There doesn't appear to be a setting that would allow me to completely compile out some or all of the logs if desired?
True?

MDJ

--
You received this message because you are subscribed to the Google Groups "CocoaLumberjack" group.
To view this discussion on the web visit https://groups.google.com/d/msg/cocoalumberjack/-/mqoMPvF6gisJ.
To post to this group, send email to cocoalumberjack@googlegroups.com.
To unsubscribe from this group, send email to cocoalumberjack+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages