[gnome-builder] object: add logging helpers for IdeObject
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] object: add logging helpers for IdeObject
- Date: Sat, 6 Jan 2018 07:45:14 +0000 (UTC)
commit 53d9bf5ba513366891d2151a39cf5d6631846c88
Author: Christian Hergert <chergert redhat com>
Date: Fri Jan 5 23:44:32 2018 -0800
object: add logging helpers for IdeObject
src/libide/ide-object.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++
src/libide/ide-object.h | 8 +++++++
2 files changed, 58 insertions(+), 0 deletions(-)
---
diff --git a/src/libide/ide-object.c b/src/libide/ide-object.c
index 43da2db..956f1c5 100644
--- a/src/libide/ide-object.c
+++ b/src/libide/ide-object.c
@@ -25,6 +25,8 @@
#include "ide-debug.h"
#include "ide-object.h"
+#include "application/ide-application.h"
+
/**
* SECTION:ide-object
* @title: IdeObject
@@ -773,3 +775,51 @@ ide_object_notify_in_main (gpointer instance,
g_timeout_add (0, ide_object_notify_in_main_cb, notify);
}
+
+void
+ide_object_message (gpointer instance,
+ const gchar *format,
+ ...)
+{
+ g_autofree gchar *str = NULL;
+ IdeContext *context;
+ va_list args;
+
+ g_return_if_fail (IDE_IS_MAIN_THREAD ());
+ g_return_if_fail (GTK_IS_WIDGET (instance));
+
+ va_start (args, format);
+ str = g_strdup_vprintf (format, args);
+ va_end (args);
+
+ context = ide_object_get_context (instance);
+
+ if (context != NULL)
+ ide_context_emit_log (context, G_LOG_LEVEL_MESSAGE, str, -1);
+ else
+ g_message ("%s", str);
+}
+
+void
+ide_object_warning (gpointer instance,
+ const gchar *format,
+ ...)
+{
+ g_autofree gchar *str = NULL;
+ IdeContext *context;
+ va_list args;
+
+ g_return_if_fail (IDE_IS_MAIN_THREAD ());
+ g_return_if_fail (GTK_IS_WIDGET (instance));
+
+ va_start (args, format);
+ str = g_strdup_vprintf (format, args);
+ va_end (args);
+
+ context = ide_object_get_context (instance);
+
+ if (context != NULL)
+ ide_context_emit_log (context, G_LOG_LEVEL_WARNING, str, -1);
+ else
+ g_warning ("%s", str);
+}
diff --git a/src/libide/ide-object.h b/src/libide/ide-object.h
index bdde72c..33c5ec0 100644
--- a/src/libide/ide-object.h
+++ b/src/libide/ide-object.h
@@ -73,5 +73,13 @@ void ide_object_release (IdeObject *self);
IDE_AVAILABLE_IN_ALL
void ide_object_notify_in_main (gpointer instance,
GParamSpec *pspec);
+IDE_AVAILABLE_IN_3_28
+void ide_object_message (gpointer instance,
+ const gchar *format,
+ ...) G_GNUC_PRINTF (2, 3);
+IDE_AVAILABLE_IN_3_28
+void ide_object_warning (gpointer instance,
+ const gchar *format,
+ ...) G_GNUC_PRINTF (2, 3);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]