[gnome-builder] libide-core: improve log initialization
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] libide-core: improve log initialization
- Date: Tue, 12 Jul 2022 06:39:08 +0000 (UTC)
commit 3a372fb4b3351ce0e0ed37bf6708c740136d4614
Author: Christian Hergert <chergert redhat com>
Date: Mon Jul 11 16:29:55 2022 -0700
libide-core: improve log initialization
We want most of this API internal and dropped from libide-core.h.
src/libide/core/ide-log-private.h | 34 ++++++++++++++++++++++++++++++++++
src/libide/core/ide-log.c | 32 +++++++-------------------------
src/libide/core/ide-log.h | 13 ++-----------
src/main.c | 3 ++-
4 files changed, 45 insertions(+), 37 deletions(-)
---
diff --git a/src/libide/core/ide-log-private.h b/src/libide/core/ide-log-private.h
new file mode 100644
index 000000000..331d33264
--- /dev/null
+++ b/src/libide/core/ide-log-private.h
@@ -0,0 +1,34 @@
+/* ide-log-private.h
+ *
+ * Copyright 2022 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#pragma once
+
+#include "ide-log.h"
+
+G_BEGIN_DECLS
+
+void ide_log_init (gboolean stdout_,
+ const char *filename,
+ const char *messages_debug);
+void ide_log_increase_verbosity (void);
+void ide_log_set_verbosity (int level);
+void ide_log_shutdown (void);
+
+G_END_DECLS
diff --git a/src/libide/core/ide-log.c b/src/libide/core/ide-log.c
index 16dd3a3d3..a867eb3da 100644
--- a/src/libide/core/ide-log.c
+++ b/src/libide/core/ide-log.c
@@ -38,7 +38,7 @@
#include <unistd.h>
#include "ide-debug.h"
-#include "ide-log.h"
+#include "ide-log-private.h"
#include "ide-macros.h"
#include "ide-private.h"
@@ -84,8 +84,6 @@
* Ide.debug("This is a debug")
* Ide.error("This is a fatal error")
* ]|
- *
- * Since: 3.32
*/
typedef const gchar *(*IdeLogLevelStrFunc) (GLogLevelFlags log_level);
@@ -106,8 +104,6 @@ G_LOCK_DEFINE (channels_lock);
* On other platforms, the current thread pointer is retrieved.
*
* Returns: The task id.
- *
- * Since: 3.32
*/
static inline gint
ide_log_get_thread (void)
@@ -127,8 +123,6 @@ ide_log_get_thread (void)
*
* Returns: A string which shouldn't be modified or freed.
* Side effects: None.
- *
- * Since: 3.32
*/
static const gchar *
ide_log_level_str (GLogLevelFlags log_level)
@@ -172,8 +166,6 @@ ide_log_level_str_with_color (GLogLevelFlags log_level)
* @message: A string log message.
*
* Writes @message to @channel and flushes the channel.
- *
- * Since: 3.32
*/
static void
ide_log_write_to_channel (GIOChannel *channel,
@@ -192,8 +184,6 @@ ide_log_write_to_channel (GIOChannel *channel,
*
* Default log handler that will dispatch log messages to configured logging
* destinations.
- *
- * Since: 3.32
*/
static void
ide_log_handler (const gchar *log_domain,
@@ -274,16 +264,16 @@ ide_log_handler (const gchar *log_domain,
* ide_log_init:
* @stdout_: Indicates logging should be written to stdout.
* @filename: An optional file in which to store logs.
+ * @messages_debug: the value of G_MESSAGES_DEBUG environment variable
*
* Initializes the logging subsystem. This should be called from
* the application entry point only. Secondary calls to this function
* will do nothing.
- *
- * Since: 3.32
*/
void
-ide_log_init (gboolean stdout_,
- const gchar *filename)
+ide_log_init (gboolean stdout_,
+ const char *filename,
+ const char *messages_debug)
{
static gsize initialized = FALSE;
GIOChannel *channel;
@@ -305,7 +295,7 @@ ide_log_init (gboolean stdout_,
log_level_str_func = ide_log_level_str_with_color;
}
- domains = g_strdup (g_getenv ("G_MESSAGES_DEBUG"));
+ domains = g_strdup (messages_debug);
if (!ide_str_empty0 (domains) && strcmp (domains, "all") != 0)
has_domains = TRUE;
@@ -319,8 +309,6 @@ ide_log_init (gboolean stdout_,
*
* Cleans up after the logging subsystem and restores the original
* log handler.
- *
- * Since: 3.32
*/
void
ide_log_shutdown (void)
@@ -352,8 +340,6 @@ ide_log_shutdown (void)
* line.
*
* Calling this method more than four times is acceptable.
- *
- * Since: 3.32
*/
void
ide_log_increase_verbosity (void)
@@ -366,10 +352,8 @@ ide_log_increase_verbosity (void)
*
* Retrieves the log verbosity, which is the number of times -v was
* provided on the command line.
- *
- * Since: 3.32
*/
-gint
+int
ide_log_get_verbosity (void)
{
return log_verbosity;
@@ -380,8 +364,6 @@ ide_log_get_verbosity (void)
*
* Sets the explicit verbosity. Generally you want to use
* ide_log_increase_verbosity() instead of this function.
- *
- * Since: 3.32
*/
void
ide_log_set_verbosity (gint level)
diff --git a/src/libide/core/ide-log.h b/src/libide/core/ide-log.h
index c8052dca4..7c80faf6f 100644
--- a/src/libide/core/ide-log.h
+++ b/src/libide/core/ide-log.h
@@ -30,16 +30,7 @@
G_BEGIN_DECLS
-IDE_AVAILABLE_IN_3_32
-void ide_log_init (gboolean stdout_,
- const gchar *filename);
-IDE_AVAILABLE_IN_3_32
-void ide_log_increase_verbosity (void);
-IDE_AVAILABLE_IN_3_32
-gint ide_log_get_verbosity (void);
-IDE_AVAILABLE_IN_3_32
-void ide_log_set_verbosity (gint level);
-IDE_AVAILABLE_IN_3_32
-void ide_log_shutdown (void);
+IDE_AVAILABLE_IN_ALL
+int ide_log_get_verbosity (void);
G_END_DECLS
diff --git a/src/main.c b/src/main.c
index e220cfbeb..31aad183a 100644
--- a/src/main.c
+++ b/src/main.c
@@ -41,6 +41,7 @@
#include "ide-application-private.h"
#include "ide-build-ident.h"
#include "ide-thread-private.h"
+#include "ide-log-private.h"
#include "ide-terminal-private.h"
#include "ide-private.h"
@@ -245,7 +246,7 @@ main (gint argc,
* format. If we deferred this to GApplication, we'd get them in
* multiple formats.
*/
- ide_log_init (TRUE, NULL);
+ ide_log_init (TRUE, NULL, messages_debug);
/* Extract options like -vvvv */
early_params_check (&argc, &argv, &standalone, &type, &plugin, &dbus_address);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]