[Bug 33660] Add tp_debug_sender_is_enabled()

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Fri Jan 28 19:13:17 CET 2011


--- Comment #2 from Will Thompson <will.thompson at collabora.co.uk> 2011-01-28 10:13:17 PST ---
(In reply to comment #1)
> +  g_return_val_if_fail (self != NULL, FALSE);
> +  g_return_val_if_fail (TP_IS_DEBUG_SENDER (self), FALSE);
> Just ooi, why both of these?
> Go go though.

I believed that TP_IS_DEBUG_SENDER (NULL) returned TRUE. But I am wrong.

It has occurred to me that a different way to do this would be to have a
variation on the theme of tp_debug_sender_add_message() like this:

tp_debug_sender_add_message_vprintf (TpDebugSender *self,
    GLogLevelFlags level,
    const gchar *domain,
    const gchar *format,
    va_args args)
  GTimeVal now;
  gchar *message;

  if (!self->priv->enabled)

  va_start (args, format);
  message = g_strdup_vprintf (format, args);
  va_end (args);
  g_get_current_time (&now);

  tp_debug_sender_add_message (dbg, &now, domain, level, message);


This would mean formatting the message twice in the worst case (once for
calling g_log() directly, once in tp_debug_sender_add_message_vprintf) but
would mean that speculative logging could be turned off in one place for the
entire platform.

If we were feeling particularly advanced, this function could return the
message if it does build it. So the caller could say:

  gchar *message = tp_debug_sender_add_message_vprintf()

  if (flag & flags || level > G_LOG_LEVEL_DEBUG)
      if (message == NULL)
          va_start (args, format);
          message = g_strdup_vprintf (format, args);
          va_end (args);

Now we're getting into micro-optimizations though.

Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.

More information about the telepathy-bugs mailing list