Greenbone Vulnerability Management Libraries 22.32.0
logging_domain.h File Reference

Implementation of logging domain handling. More...

#include <glib.h>
Include dependency graph for logging_domain.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef struct gvm_logging_domain gvm_logging_domain_t

Functions

gvm_logging_domain_tgvm_logging_domain_new (gchar *log_domain)
 Function to initialize logging instance.
void gvm_logging_domain_free (gvm_logging_domain_t *log_domain)
 Frees the resources associated with the given logging domain.
gchar * gvm_logging_domain_get_log_domain (gvm_logging_domain_t *log_domain)
gchar * gvm_logging_domain_get_log_file (gvm_logging_domain_t *log_domain)
void gvm_logging_domain_set_log_file (gvm_logging_domain_t *log_domain, gchar *log_file)
 Sets the log file for the logging domain.
gchar * gvm_logging_domain_get_prepend_string (gvm_logging_domain_t *log_domain)
void gvm_logging_domain_set_prepend_string (gvm_logging_domain_t *log_domain, gchar *prepend_string)
 Sets the preprend string for the logging domain.
gchar * gvm_logging_domain_get_prepend_time_format (gvm_logging_domain_t *log_domain)
void gvm_logging_domain_set_prepend_time_format (gvm_logging_domain_t *log_domain, gchar *prepend_time_format)
 Sets the prepend time format for the logging domain.
GLogLevelFlags * gvm_logging_domain_get_default_level (gvm_logging_domain_t *log_domain)
void gvm_logging_domain_set_default_level (gvm_logging_domain_t *log_domain, GLogLevelFlags default_level)
 Sets the default log level for the logging domain.
gchar * gvm_logging_domain_get_syslog_facility (gvm_logging_domain_t *log_domain)
void gvm_logging_domain_set_syslog_facility (gvm_logging_domain_t *log_domain, gchar *syslog_facility)
 Sets the syslog facility for the logging domain.
gchar * gvm_logging_domain_get_syslog_ident (gvm_logging_domain_t *log_domain)
void gvm_logging_domain_set_syslog_ident (gvm_logging_domain_t *log_domain, gchar *syslog_ident)
 Sets the syslog ident for the logging domain.
gchar * gvm_logging_domain_get_prepend_separator (gvm_logging_domain_t *log_domain)
void gvm_logging_domain_set_prepend_separator (gvm_logging_domain_t *log_domain, gchar *prepend_separator)
 Sets the prepend separator for the logging domain.
GIOChannel * gvm_logging_domain_get_log_channel (gvm_logging_domain_t *log_domain)
void gvm_logging_domain_set_log_channel (gvm_logging_domain_t *log_domain, GIOChannel *log_channel)
 Sets the log channel for the logging domain.

Detailed Description

Implementation of logging domain handling.

Definition in file logging_domain.h.

Typedef Documentation

◆ gvm_logging_domain_t

Definition at line 15 of file logging_domain.h.

Function Documentation

◆ gvm_logging_domain_free()

void gvm_logging_domain_free ( gvm_logging_domain_t * log_domain)

Frees the resources associated with the given logging domain.

Frees the resources associated with the given logging domain. This function should be called when the logging domain is no longer needed to ensure that all allocated resources are properly released.

Parameters
log_domainA pointer to a gvm_logging_t structure representing the logging domain to be freed.

Definition at line 72 of file logging_domain.c.

73{
74 g_free (log_domain->log_domain);
75 g_free (log_domain->prepend_string);
76 g_free (log_domain->prepend_time_format);
77 g_free (log_domain->log_file);
78 g_free (log_domain->default_level);
79 g_free (log_domain->syslog_facility);
80 g_free (log_domain->syslog_ident);
81 g_free (log_domain->prepend_separator);
82
83 /* Drop the reference to the GIOChannel. */
84 if (log_domain->log_channel)
85 g_io_channel_unref (log_domain->log_channel);
86
87 /* Free the struct. */
88 g_free (log_domain);
89}
GLogLevelFlags * default_level
What severity level to use as default.
GIOChannel * log_channel
Gio Channel - FD holder for logfile.
gchar * log_domain
Affected logdomain e.g libnasl.
gchar * log_file
Where to log to.
gchar * syslog_facility
Syslog facility to use for syslog logging.
gchar * syslog_ident
Syslog ident to use for syslog logging.
gchar * prepend_time_format
If prependstring has t, format for strftime.
gchar * prepend_string
Prepend this string before every message.

References gvm_logging_domain::default_level, gvm_logging_domain::log_channel, gvm_logging_domain::log_domain, gvm_logging_domain::log_file, gvm_logging_domain::prepend_separator, gvm_logging_domain::prepend_string, gvm_logging_domain::prepend_time_format, gvm_logging_domain::syslog_facility, and gvm_logging_domain::syslog_ident.

Referenced by Ensure(), Ensure(), Ensure(), and free_log_configuration().

Here is the caller graph for this function:

◆ gvm_logging_domain_get_default_level()

GLogLevelFlags * gvm_logging_domain_get_default_level ( gvm_logging_domain_t * log_domain)

Retrieves the default log level associated with the given logging domain.

The returned default log level is still owned by the logging domain and should not be freed by the caller.

Parameters
log_domainA pointer to a gvm_logging_domain_t structure.
Returns
The default log level associated with the logging domain or NULL

Definition at line 221 of file logging_domain.c.

222{
223 return log_domain->default_level;
224}

References gvm_logging_domain::default_level.

Referenced by Ensure(), Ensure(), Ensure(), and gvm_log_func().

Here is the caller graph for this function:

◆ gvm_logging_domain_get_log_channel()

GIOChannel * gvm_logging_domain_get_log_channel ( gvm_logging_domain_t * log_domain)

Retrieves the log channel associated with the given logging domain.

The returned log channel is still owned by the logging domain and should not be freed by the caller.

Parameters
log_domainA pointer to a gvm_logging_domain_t structure.
Returns
The log channel associated with the logging domain or NULL

Definition at line 356 of file logging_domain.c.

357{
358 return log_domain->log_channel;
359}

References gvm_logging_domain::log_channel.

Referenced by Ensure(), Ensure(), and gvm_log_func().

Here is the caller graph for this function:

◆ gvm_logging_domain_get_log_domain()

gchar * gvm_logging_domain_get_log_domain ( gvm_logging_domain_t * log_domain)

Retrieves the log domain associated with the given logging domain.

The returned log domain is still owned by the logging domain and should not be freed by the caller.

Parameters
log_domainA pointer to a gvm_logging_domain_t structure.
Returns
The log domain associated with the logging domain or NULL

Definition at line 102 of file logging_domain.c.

103{
104 return log_domain->log_domain;
105}

References gvm_logging_domain::log_domain.

Referenced by Ensure(), Ensure(), gvm_log_func(), and setup_log_handlers_internal().

Here is the caller graph for this function:

◆ gvm_logging_domain_get_log_file()

gchar * gvm_logging_domain_get_log_file ( gvm_logging_domain_t * log_domain)

Retrieves the log file associated with the given logging domain.

The returned log file is still owned by the logging domain and should not be freed by the caller.

Parameters
log_domainA pointer to a gvm_logging_domain_t structure.
Returns
The log file associated with the logging domain or NULL

Definition at line 118 of file logging_domain.c.

119{
120 return log_domain->log_file;
121}

References gvm_logging_domain::log_file.

Referenced by check_log_file(), Ensure(), Ensure(), Ensure(), and gvm_log_func().

Here is the caller graph for this function:

◆ gvm_logging_domain_get_prepend_separator()

gchar * gvm_logging_domain_get_prepend_separator ( gvm_logging_domain_t * log_domain)

Retrieves the prepend separator associated with the given logging domain.

The returned prepend separator is still owned by the logging domain and should not be freed by the caller.

Parameters
log_domainA pointer to a gvm_logging_domain_t structure.
Returns
The prepend separator associated with the logging domain or NULL

Definition at line 322 of file logging_domain.c.

323{
324 return log_domain->prepend_separator;
325}

References gvm_logging_domain::prepend_separator.

Referenced by Ensure(), Ensure(), Ensure(), and gvm_log_func().

Here is the caller graph for this function:

◆ gvm_logging_domain_get_prepend_string()

gchar * gvm_logging_domain_get_prepend_string ( gvm_logging_domain_t * log_domain)

Retrieves the prepend string associated with the given logging domain.

The returned prepend string is still owned by the logging domain and should not be freed by the caller.

Parameters
log_domainA pointer to a gvm_logging_domain_t structure.
Returns
The prepend string associated with the logging domain or NULL

Definition at line 152 of file logging_domain.c.

153{
154 return log_domain->prepend_string;
155}

References gvm_logging_domain::prepend_string.

Referenced by Ensure(), Ensure(), Ensure(), and gvm_log_func().

Here is the caller graph for this function:

◆ gvm_logging_domain_get_prepend_time_format()

gchar * gvm_logging_domain_get_prepend_time_format ( gvm_logging_domain_t * log_domain)

Retrieves the prepend time format associated with the given logging domain.

The returned prepend time format is still owned by the logging domain and should not be freed by the caller.

Parameters
log_domainA pointer to a gvm_logging_domain_t structure.
Returns
The prepend time format associated with the logging domain or NULL

Definition at line 186 of file logging_domain.c.

187{
188 return log_domain->prepend_time_format;
189}

References gvm_logging_domain::prepend_time_format.

Referenced by Ensure(), Ensure(), Ensure(), and gvm_log_func().

Here is the caller graph for this function:

◆ gvm_logging_domain_get_syslog_facility()

gchar * gvm_logging_domain_get_syslog_facility ( gvm_logging_domain_t * log_domain)

Retrieves the syslog facility associated with the given logging domain.

The returned syslog facility is still owned by the logging domain and should not be freed by the caller.

Parameters
log_domainA pointer to a gvm_logging_domain_t structure.
Returns
The syslog facility associated with the logging domain or NULL

Definition at line 255 of file logging_domain.c.

256{
257 return log_domain->syslog_facility;
258}

References gvm_logging_domain::syslog_facility.

Referenced by Ensure(), Ensure(), Ensure(), and gvm_log_func().

Here is the caller graph for this function:

◆ gvm_logging_domain_get_syslog_ident()

gchar * gvm_logging_domain_get_syslog_ident ( gvm_logging_domain_t * log_domain)

Retrieves the syslog ident associated with the given logging domain.

The returned syslog ident is still owned by the logging domain and should not be freed by the caller.

Parameters
log_domainA pointer to a gvm_logging_domain_t structure.
Returns
The syslog ident associated with the logging domain or NULL

Definition at line 289 of file logging_domain.c.

290{
291 return log_domain->syslog_ident;
292}

References gvm_logging_domain::syslog_ident.

Referenced by Ensure(), Ensure(), Ensure(), and gvm_log_func().

Here is the caller graph for this function:

◆ gvm_logging_domain_new()

gvm_logging_domain_t * gvm_logging_domain_new ( gchar * log_domain)

Function to initialize logging instance.

This function is responsible for setting up the logging mechanism and returning a pointer to the logging struct. It ensures that the logging struct is properly configured before use.

Parameters
log_domainA string containing the log domain to be used. Gets owned by the logging domain and must not be freed.
Returns
gvm_logging_t* Pointer to the new logging struct.

Definition at line 40 of file logging_domain.c.

41{
42 gvm_logging_domain_t *log_domain_entry;
43 /* Create the struct. */
44 log_domain_entry = g_malloc (sizeof (gvm_logging_domain_t));
45 /* Set the logdomain. */
46 log_domain_entry->log_domain = log_domain;
47 /* Initialize everything else to NULL. */
48 log_domain_entry->prepend_string = NULL;
49 log_domain_entry->prepend_time_format = NULL;
50 log_domain_entry->log_file = NULL;
51 log_domain_entry->default_level = NULL;
52 log_domain_entry->log_channel = NULL;
53 log_domain_entry->syslog_facility = NULL;
54 log_domain_entry->syslog_ident = NULL;
55 log_domain_entry->prepend_separator = NULL;
56
57 return log_domain_entry;
58}
struct gvm_logging_domain gvm_logging_domain_t

References gvm_logging_domain::default_level, gvm_logging_domain::log_channel, gvm_logging_domain::log_domain, gvm_logging_domain::log_file, gvm_logging_domain::prepend_separator, gvm_logging_domain::prepend_string, gvm_logging_domain::prepend_time_format, gvm_logging_domain::syslog_facility, and gvm_logging_domain::syslog_ident.

Referenced by Ensure(), Ensure(), Ensure(), and load_log_configuration().

Here is the caller graph for this function:

◆ gvm_logging_domain_set_default_level()

void gvm_logging_domain_set_default_level ( gvm_logging_domain_t * log_domain,
GLogLevelFlags default_level )

Sets the default log level for the logging domain.

This function sets the default log level for the specified logging domain.

Parameters
log_domainThe logging domain for which the default log level is to be set.
default_levelThe default log level to set.

Definition at line 236 of file logging_domain.c.

238{
239 g_free (log_domain->default_level);
240 log_domain->default_level = g_malloc (sizeof (gint));
241 *log_domain->default_level = default_level;
242}

References gvm_logging_domain::default_level.

Referenced by Ensure(), and load_log_configuration().

Here is the caller graph for this function:

◆ gvm_logging_domain_set_log_channel()

void gvm_logging_domain_set_log_channel ( gvm_logging_domain_t * log_domain,
GIOChannel * log_channel )

Sets the log channel for the logging domain.

This function sets the log channel for the specified logging domain.

Parameters
log_domainThe logging domain for which the log channel is to be set.
log_channelThe log channel to set. Gets referenced by the logging and unreferenced when the logging domain is freed.

Definition at line 371 of file logging_domain.c.

373{
374 if (log_domain->log_channel)
375 g_io_channel_unref (log_domain->log_channel);
376 log_domain->log_channel = log_channel;
377 if (log_channel)
378 g_io_channel_ref (log_channel);
379}

References gvm_logging_domain::log_channel.

Referenced by Ensure(), and gvm_log_func().

Here is the caller graph for this function:

◆ gvm_logging_domain_set_log_file()

void gvm_logging_domain_set_log_file ( gvm_logging_domain_t * log_domain,
gchar * log_file )

Sets the log file for the logging domain.

This function sets the file to which log messages for the specified logging domain will be written.

Parameters
log_domainThe logging domain for which the log file is to be set.
log_fileThe path to the log file. Gets owned by the logging domain and must not be freed.

Definition at line 134 of file logging_domain.c.

136{
137 g_free (log_domain->log_file);
138 log_domain->log_file = log_file;
139}

References gvm_logging_domain::log_file.

Referenced by Ensure(), Ensure(), and load_log_configuration().

Here is the caller graph for this function:

◆ gvm_logging_domain_set_prepend_separator()

void gvm_logging_domain_set_prepend_separator ( gvm_logging_domain_t * log_domain,
gchar * prepend_separator )

Sets the prepend separator for the logging domain.

This function sets the prepend separator for the specified logging domain.

Parameters
log_domainThe logging domain for which the prepend separator is to be set.
prepend_separatorThe prepend separator to set. Gets owned by the logging domain and must not be freed.

Definition at line 338 of file logging_domain.c.

340{
341 g_free (log_domain->prepend_separator);
342 log_domain->prepend_separator = prepend_separator;
343}

References gvm_logging_domain::prepend_separator.

Referenced by Ensure(), and load_log_configuration().

Here is the caller graph for this function:

◆ gvm_logging_domain_set_prepend_string()

void gvm_logging_domain_set_prepend_string ( gvm_logging_domain_t * log_domain,
gchar * prepend_string )

Sets the preprend string for the logging domain.

This function sets the string that will be prepended to every log message

Parameters
log_domainThe logging domain for which the prepend string is to be set.
prepend_stringThe string to prepend. Gets owned by the logging domain and must not be freed.

Definition at line 168 of file logging_domain.c.

170{
171 g_free (log_domain->prepend_string);
172 log_domain->prepend_string = prepend_string;
173}

References gvm_logging_domain::prepend_string.

Referenced by Ensure(), and load_log_configuration().

Here is the caller graph for this function:

◆ gvm_logging_domain_set_prepend_time_format()

void gvm_logging_domain_set_prepend_time_format ( gvm_logging_domain_t * log_domain,
gchar * prepend_time_format )

Sets the prepend time format for the logging domain.

This function sets the time format that will be used when t is present in the prepend string.

Parameters
log_domainThe logging domain for which the prepend time format is to be set.
prepend_time_formatThe time format to set. Gets owned by the logging domain and must not be freed.

Definition at line 203 of file logging_domain.c.

205{
206 g_free (log_domain->prepend_time_format);
207 log_domain->prepend_time_format = prepend_time_format;
208}

References gvm_logging_domain::prepend_time_format.

Referenced by Ensure(), and load_log_configuration().

Here is the caller graph for this function:

◆ gvm_logging_domain_set_syslog_facility()

void gvm_logging_domain_set_syslog_facility ( gvm_logging_domain_t * log_domain,
gchar * syslog_facility )

Sets the syslog facility for the logging domain.

This function sets the syslog facility for the specified logging domain.

Parameters
log_domainThe logging domain for which the syslog facility is to be set.
syslog_facilityThe syslog facility to set. Gets owned by the logging domain and must not be freed.

Definition at line 271 of file logging_domain.c.

273{
274 g_free (log_domain->syslog_facility);
275 log_domain->syslog_facility = syslog_facility;
276}

References gvm_logging_domain::syslog_facility.

Referenced by Ensure(), and load_log_configuration().

Here is the caller graph for this function:

◆ gvm_logging_domain_set_syslog_ident()

void gvm_logging_domain_set_syslog_ident ( gvm_logging_domain_t * log_domain,
gchar * syslog_ident )

Sets the syslog ident for the logging domain.

This function sets the syslog ident for the specified logging domain.

Parameters
log_domainThe logging domain for which the syslog ident is to be set.
syslog_identThe syslog ident to set. Gets owned by the logging domain and must not be freed.

Definition at line 304 of file logging_domain.c.

306{
307 g_free (log_domain->syslog_ident);
308 log_domain->syslog_ident = syslog_ident;
309}

References gvm_logging_domain::syslog_ident.

Referenced by Ensure(), and load_log_configuration().

Here is the caller graph for this function: