OpenVAS Libraries
9.0.3
|
Implementation of logging methods for OpenVAS. More...
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <syslog.h>
#include <unistd.h>
#include <stdarg.h>
#include <libgen.h>
#include <errno.h>
#include <gnutls/gnutls.h>
#include "openvas_logging.h"
Go to the source code of this file.
Data Structures | |
struct | openvas_logging_t |
Macros | |
#define | SYSLOG_NAMES |
Functions | |
gchar * | get_time (gchar *time_fmt) |
Returns time as specified in time_fmt strftime format. 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 | openvas_log_silent (const char *log_domain, GLogLevelFlags log_level, const char *message, gpointer openvas_log_config_list) |
Returns immediately. More... | |
void | openvas_log_func (const char *log_domain, GLogLevelFlags log_level, const char *message, gpointer openvas_log_config_list) |
Creates the formatted string and outputs it to the log destination. More... | |
void | setup_log_handlers (GSList *openvas_log_config_list) |
Sets up routing of logdomains to log handlers. More... | |
void | setup_legacy_log_handler (void(*handler)(const char *, va_list)) |
Sets up a simple logging function. More... | |
void | log_legacy_write (const char *format,...) |
Legacy function to write a log message. More... | |
void | log_legacy_fflush (void) |
Legacy function to flush a log message. More... | |
Implementation of logging methods for OpenVAS.
This file contains all methods needed for openvas logging. To enable logging, methods in this file are called. Have a look at openvas-server/openvassd/openvassd.c for an example.
The module reuses glib datatypes and api for memory management and logging.
Definition in file openvas_logging.c.
#define SYSLOG_NAMES |
Definition at line 44 of file openvas_logging.c.
void free_log_configuration | ( | GSList * | log_domain_list | ) |
Frees all resources loaded by the config loader.
log_domain_list | Head of the link list. |
Definition at line 298 of file openvas_logging.c.
References openvas_logging_t::default_level, openvas_logging_t::log_channel, openvas_logging_t::log_domain, openvas_logging_t::log_file, openvas_logging_t::prepend_string, openvas_logging_t::prepend_time_format, and openvas_logging_t::syslog_ident.
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". |
Definition at line 96 of file openvas_logging.c.
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. |
Definition at line 176 of file openvas_logging.c.
References openvas_logging_t::default_level, openvas_logging_t::log_channel, openvas_logging_t::log_domain, openvas_logging_t::log_file, openvas_logging_t::prepend_string, openvas_logging_t::prepend_time_format, openvas_logging_t::syslog_facility, and openvas_logging_t::syslog_ident.
void log_legacy_fflush | ( | void | ) |
Legacy function to flush a log message.
This function shall be used instead of fflush for log messages via fprintf. It will eventually be removed.
Definition at line 851 of file openvas_logging.c.
Referenced by openvas_get_socket_from_connection().
void log_legacy_write | ( | const char * | format, |
... | |||
) |
Legacy function to write a log message.
This function shall be used instead of fprintf in legacy code. It will eventually be replaced by glib log functions.
format | printf style format string |
Definition at line 832 of file openvas_logging.c.
Referenced by arg_dump(), build_encode_URL(), close_stream_connection(), exec_nasl_script(), get_plugin_preference_fname(), getinterfaces(), getipv4routes(), getipv6routes(), ids_open_sock_tcp(), internal_recv(), internal_send(), nasl_cert_close(), nasl_cert_open(), nasl_cert_query(), nasl_smb_connect(), nasl_smb_file_group_sid(), nasl_smb_file_owner_sid(), nasl_smb_file_SDDL(), nasl_smb_file_trustee_rights(), nasl_socket_get_error(), nasl_win_cmd_exec(), nasl_wmi_connect(), nasl_wmi_connect_reg(), nasl_wmi_connect_rsop(), nasl_wmi_query(), nasl_wmi_query_rsop(), nasl_wmi_reg_create_key(), nasl_wmi_reg_delete_key(), nasl_wmi_reg_enum_key(), nasl_wmi_reg_enum_value(), nasl_wmi_reg_get_bin_val(), nasl_wmi_reg_get_dword_val(), nasl_wmi_reg_get_ex_string_val(), nasl_wmi_reg_get_mul_string_val(), nasl_wmi_reg_get_qword_val(), nasl_wmi_reg_get_sz(), nasl_wmi_reg_set_dword_val(), nasl_wmi_reg_set_ex_string_val(), nasl_wmi_reg_set_qword_val(), nasl_wmi_reg_set_string_val(), nrecv(), open_sock_option(), open_stream_connection_ext(), openvas_get_socket_from_connection(), openvas_popen4(), plugin_run_openvas_tcp_scanner(), rm_packet(), socket_get_cert(), socket_get_ssl_ciphersuite(), socket_get_ssl_compression(), socket_get_ssl_session_id(), socket_get_ssl_version(), socket_negotiate_ssl(), tlserror(), and v6_sendpacket().
void openvas_log_func | ( | const char * | log_domain, |
GLogLevelFlags | log_level, | ||
const char * | message, | ||
gpointer | openvas_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. |
openvas_log_config_list | A pointer to the configuration linked list. |
Definition at line 389 of file openvas_logging.c.
Referenced by setup_log_handlers().
void openvas_log_silent | ( | const char * | log_domain, |
GLogLevelFlags | log_level, | ||
const char * | message, | ||
gpointer | openvas_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. |
openvas_log_config_list | A pointer to the configuration linked list. |
Definition at line 346 of file openvas_logging.c.
void setup_legacy_log_handler | ( | void(*)(const char *, va_list) | handler | ) |
Sets up a simple logging function.
The openvas-scanner has not yet been changed to use the new logging facility. However, it uses library functions and those should use a proper log function instead of writing to stderr. This function can be used to register an existing log handler which will then be used by log_legacy_write.
handler | A printf style log handler or NULL to use stderr. |
Definition at line 817 of file openvas_logging.c.
void setup_log_handlers | ( | GSList * | openvas_log_config_list | ) |
Sets up routing of logdomains to log handlers.
Iterates over the link list and adds the groups to the handler.
openvas_log_config_list | A pointer to the configuration linked list. |
Definition at line 742 of file openvas_logging.c.
References openvas_logging_t::log_domain, and openvas_log_func().