Logging

Logging — Standard logging facilities for Builder

Functions

Description

This module manages the logging facilities in Builder. It involves formatting the standard output and error logs as well as filtering logs based on their GLogLevelFlags.

Generally speaking, you want to continue using the GLib logging API such as g_debug(), g_warning(), g_message(), or g_error(). These functions will redirect their logging information to this module who will format the log message appropriately.

If you are writing code for Builder that is in C, you want to ensure you set the G_LOG_DOMAIN define at the top of your file (after the license) as such:

Logging from C

1
2
3
4
5
6
7
#define G_LOG_DOMAIN "my-module"
...
static void
some_function (void)
{
  g_debug ("Use normal logging facilities");
}

Logging from Python

If you are writing an extension to Builder from Python, you may use the helper functions provided by our Ide python module.

1
2
3
4
5
from gi.repository import Ide

Ide.warning("This is a warning")
Ide.debug("This is a debug")
Ide.error("This is a fatal error")

Functions

ide_log_init ()

void
ide_log_init (gboolean stdout_,
              const gchar *filename);

Initializes the logging subsystem. This should be called from the application entry point only. Secondary calls to this function will do nothing.

Parameters

stdout_

Indicates logging should be written to stdout.

 

filename

An optional file in which to store logs.

 

Since: 3.16


ide_log_increase_verbosity ()

void
ide_log_increase_verbosity (void);

Increases the amount of logging that will occur. By default, only warning and above will be displayed.

Calling this once will cause G_LOG_LEVEL_MESSAGE to be displayed. Calling this twice will cause G_LOG_LEVEL_INFO to be displayed. Calling this thrice will cause G_LOG_LEVEL_DEBUG to be displayed. Calling this four times will cause IDE_LOG_LEVEL_TRACE to be displayed.

Note that many DEBUG and TRACE level log messages are only compiled into debug builds, and therefore will not be available in release builds.

This method is meant to be called for every -v provided on the command line.

Calling this method more than four times is acceptable.

Since: 3.20


ide_log_get_verbosity ()

gint
ide_log_get_verbosity (void);

Retrieves the log verbosity, which is the number of times -v was provided on the command line.

Since: 3.20


ide_log_set_verbosity ()

void
ide_log_set_verbosity (gint level);

Sets the explicit verbosity. Generally you want to use ide_log_increase_verbosity() instead of this function.

Since: 3.20


ide_log_shutdown ()

void
ide_log_shutdown (void);

Cleans up after the logging subsystem and restores the original log handler.

Since: 3.16

Types and Values