[Mono-bugs] [Bug 666461] Log.Debug() doesn't seem to be working in P11

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Mon Jan 24 16:53:24 EST 2011



--- Comment #1 from Jonathan Pryor <jpryor at novell.com> 2011-01-24 21:53:23 UTC ---
So, the problem is a fundamental misunderstanding of Log (which the docs don't
help with).

In order to avoid extraneous string marshaling costs (particularly for
messages, as I'm assuming messages are fairly long), Log.Debug/Error/etc. are
implemented like;

    public static int Debug(string tag, string message)
        if (!IsLoggable (tag, LogPriority.Debug)
            return 0;
        return _d (tag, msg);

I thought it was a nice performance optimization...

The problem is that Log.IsLoggable() apparently has no relation to the actual
logging methods; try this in Java:

    Log.i("*jonp*", "DEBUG enabled? " + Log.isLoggable(TAG, Log.DEBUG));
    Log.d(TAG, "This is my DEBUG message");

and the output is:

    I/*jonp*  (  585): DEBUG enabled? false
    D/*jonp*  (  585): This is my DEBUG message

Notice that Log.isLoggable() says that the message is not loggable (it returns
`false`), yet it logs the message anyway.  (However, Log.d() doesn't say that
it pays any attention to isLoggable(), so I'm not even sure that the
isLoggable() method is _for_, other than an "opt-in suggestion"...)

Thus, the question: should we continue with the IsLoggable() use, or skip it

Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.

More information about the mono-bugs mailing list