Back to index

libunity  5.92.0
unity-trace.c
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2011 Canonical, Ltd.
00003  *
00004  * This library is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU Lesser General Public License
00006  * version 3.0 as published by the Free Software Foundation.
00007  *
00008  * This library is distributed in the hope that it will be useful,
00009  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011  * GNU Lesser General Public License version 3.0 for more details.
00012  *
00013  * You should have received a copy of the GNU Lesser General Public
00014  * License along with this library. If not, see
00015  * <http://www.gnu.org/licenses/>.
00016  *
00017  * Authored by Mikkel Kamstrup Erlandsen <mikkel.kamstrup@canonical.com>
00018  */
00019 
00020 #include <glib-object.h>
00021 
00022 #include "unity-trace.h"
00023 
00024 void
00025 unity_trace_log_object_va (void        *obj,
00026                            const gchar *format,
00027                            va_list      args)
00028 {
00029   GString   *tmp;
00030 
00031   if (!G_IS_OBJECT(obj)) {
00032     g_critical ("Failed to log '%s' for object. Not an object.", format);
00033     return;
00034   }
00035 
00036   tmp = g_string_sized_new (64);
00037   g_string_printf (tmp, "(%s@%p): ", g_type_name(G_OBJECT_TYPE(obj)), obj);
00038   g_string_append (tmp, format);
00039   g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, tmp->str, args);
00040 
00041   g_string_free (tmp, TRUE);
00042 }
00043 
00044 void
00045 unity_trace_log_object_real (void                 *obj,
00046                              const gchar *format,
00047                              ...)
00048 {
00049   va_list args;
00050   va_start (args, format);
00051   unity_trace_log_object_va (obj, format, args);
00052   va_end (args);
00053 }
00054