Greenbone Vulnerability Management Libraries
21.4.2
|
Implementation of logging methods. More...
#include "logging.h"
#include <errno.h>
#include <libgen.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <syslog.h>
#include <time.h>
#include <unistd.h>
Data Structures | |
struct | gvm_logging_t |
Logging stores the parameters loaded from a log configuration. More... | |
Macros | |
#define | SYSLOG_NAMES |
#define | G_LOG_DOMAIN "libgvm base" |
GLib log domain. More... | |
Functions | |
gchar * | get_time (gchar *time_fmt) |
Returns time as specified in time_fmt strftime format. More... | |
static gint | level_int_from_string (const gchar *level) |
Return the integer corresponding to a log level string. More... | |
static gint | facility_int_from_string (const gchar *facility) |
Return the integer corresponding to a syslog facility string. More... | |
GSList * | load_log_configuration (gchar *config_file) |
Loads parameters from a config file into a linked list. More... | |
void | free_log_configuration (GSList *log_domain_list) |
Frees all resources loaded by the config loader. More... | |
void | gvm_log_silent (const char *log_domain, GLogLevelFlags log_level, const char *message, gpointer gvm_log_config_list) |
Returns immediately. More... | |
static void | gvm_log_lock_init (void) |
Initialize logger_mutex mutex if it was not done before. More... | |
void | gvm_log_lock (void) |
Try to lock logger_mutex. More... | |
void | gvm_log_unlock (void) |
Unlock logger_mutex. More... | |
void | gvm_log_func (const char *log_domain, GLogLevelFlags log_level, const char *message, gpointer gvm_log_config_list) |
Creates the formatted string and outputs it to the log destination. More... | |
void | log_func_for_gnutls (int level, const char *message) |
This function logs debug messages from gnutls. More... | |
static int | check_log_file (gvm_logging_t *log_domain_entry) |
Check permissions of log file and log file directory. More... | |
int | setup_log_handlers (GSList *gvm_log_config_list) |
Sets up routing of logdomains to log handlers. More... | |
Variables | |
static GMutex * | logger_mutex = NULL |
Implementation of logging methods.
This file contains all methods needed for logging. To enable logging, methods in this file are called.
The module reuses glib datatypes and api for memory management and logging.
#define G_LOG_DOMAIN "libgvm base" |
GLib log domain.
#define SYSLOG_NAMES |
|
static |
Check permissions of log file and log file directory.
Do not check permissions if log file is syslog or empty string.
log_domain_entry | Log domain entry. |
|
static |
Return the integer corresponding to a syslog facility string.
facility | Facility name. |
void free_log_configuration | ( | GSList * | log_domain_list | ) |
Frees all resources loaded by the config loader.
log_domain_list | Head of the link list. |
gchar* get_time | ( | gchar * | time_fmt | ) |
Returns time as specified in time_fmt strftime format.
time_fmt | ptr to the string format to use. The strftime man page documents the conversion specification. An example time_fmt string is "%Y-%m-%d %H:%M:%S". |
void gvm_log_func | ( | const char * | log_domain, |
GLogLevelFlags | log_level, | ||
const char * | message, | ||
gpointer | gvm_log_config_list | ||
) |
Creates the formatted string and outputs it to the log destination.
log_domain | A string containing the message's log domain. |
log_level | Flags defining the message's log level. |
message | A string containing the log message. |
gvm_log_config_list | A pointer to the configuration linked list. |
void gvm_log_lock | ( | void | ) |
Try to lock logger_mutex.
|
static |
Initialize logger_mutex mutex if it was not done before.
void gvm_log_silent | ( | const char * | log_domain, |
GLogLevelFlags | log_level, | ||
const char * | message, | ||
gpointer | gvm_log_config_list | ||
) |
Returns immediately.
log_domain | A string containing the message's log domain. |
log_level | Flags defining the message's log level. |
message | A string containing the log message. |
gvm_log_config_list | A pointer to the configuration linked list. |
void gvm_log_unlock | ( | void | ) |
Unlock logger_mutex.
|
static |
Return the integer corresponding to a log level string.
level | Level name or integer. |
GSList* load_log_configuration | ( | gchar * | config_file | ) |
Loads parameters from a config file into a linked list.
config_file | A string containing the path to the configuration file to load. |
void log_func_for_gnutls | ( | int | level, |
const char * | message | ||
) |
This function logs debug messages from gnutls.
level | GnuTLS log level (integer from 0 to 99 according to GnuTLS documentation. |
message | GnuTLS log message. |
To enable GNUTLS debug messages, the environment variable OPENVAS_GNUTLS_DEBUG
is to be set to the desired log level as described in the GNUTLS manual.
int setup_log_handlers | ( | GSList * | gvm_log_config_list | ) |
Sets up routing of logdomains to log handlers.
Iterates over the link list and adds the groups to the handler.
gvm_log_config_list | A pointer to the configuration linked list. |
|
static |