suricata
|
#include "suricata-common.h"
#include "threads.h"
#include "util-debug.h"
#include "util-error.h"
#include "util-enum.h"
#include "util-debug-filters.h"
#include "decode.h"
#include "detect.h"
#include "packet-queue.h"
#include "threadvars.h"
#include "output.h"
#include "tm-queuehandlers.h"
#include "tm-queues.h"
#include "tm-threads.h"
#include "util-unittest.h"
#include "util-syslog.h"
#include "rust.h"
#include "conf.h"
Go to the source code of this file.
Functions | |
SCError | SCLogMessage (const SCLogLevel log_level, const char *file, const unsigned int line, const char *function, const SCError error_code, const char *message) |
Adds the global log_format to the outgoing buffer. More... | |
void | SCLog (int x, const char *file, const char *func, const int line, const char *fmt,...) |
void | SCLogErr (int x, const char *file, const char *func, const int line, const int err, const char *fmt,...) |
int | SCLogDebugEnabled (void) |
Returns whether debug messages are enabled to be logged or not. More... | |
SCLogOPBuffer * | SCLogAllocLogOPBuffer (void) |
Allocates an output buffer for an output interface. Used when we want the op_interface log_format to override the global_log_format. Currently not used. More... | |
SCLogLevel | SCLogGetLogLevel (void) |
SCLogInitData * | SCLogAllocLogInitData (void) |
Returns a pointer to a new SCLogInitData. This is a public interface intended to be used after the logging paramters are read from the conf file. More... | |
void | SCLogAppendOPIfaceCtx (SCLogOPIfaceCtx *iface_ctx, SCLogInitData *sc_lid) |
Appends an output_interface to the output_interface list sent in head. More... | |
SCLogOPIfaceCtx * | SCLogInitOPIfaceCtx (const char *iface_name, const char *log_format, int log_level, const char *arg) |
Creates a new output interface based on the arguments sent. The kind of output interface to be created is decided by the iface_name arg. If iface_name is "file", the arg argument will hold the filename to be used for logging purposes. If iface_name is "syslog", the arg argument holds the facility code. If iface_name is "console", arg is NULL. More... | |
void | SCLogInitLogModule (SCLogInitData *sc_lid) |
Initializes the logging module. More... | |
void | SCLogLoadConfig (int daemon, int verbose, uint32_t userid, uint32_t groupid) |
void | SCLogDeInitLogModule (void) |
De-Initializes the logging module. More... | |
void | SCLogRegisterTests () |
Variables | |
SCEnumCharMap | sc_log_level_map [] |
SCEnumCharMap | sc_log_op_iface_map [] |
SCLogLevel | sc_log_global_log_level |
Holds the global log level. Is the same as sc_log_config->log_level. More... | |
int | sc_log_module_initialized = 0 |
Used to indicate whether the logging module has been init or not. More... | |
int | sc_log_module_cleaned = 0 |
Used to indicate whether the logging module has been cleaned or not. More... | |
Debug utility functions
Definition in file util-debug.c.
void SCLog | ( | int | x, |
const char * | file, | ||
const char * | func, | ||
const int | line, | ||
const char * | fmt, | ||
... | |||
) |
Definition at line 603 of file util-debug.c.
References msg, sc_log_fd_filters_present, sc_log_fg_filters_present, sc_log_global_log_level, SC_LOG_MAX_LOG_MSG_LEN, SC_OK, SCLogMatchFDFilter(), SCLogMatchFGFilterBL(), SCLogMatchFGFilterWL(), and SCLogMessage().
SCLogInitData* SCLogAllocLogInitData | ( | void | ) |
Returns a pointer to a new SCLogInitData. This is a public interface intended to be used after the logging paramters are read from the conf file.
sc_lid | Pointer to the newly created SCLogInitData \initonly |
Definition at line 1146 of file util-debug.c.
References SCMalloc.
Referenced by SCLogLoadConfig().
SCLogOPBuffer* SCLogAllocLogOPBuffer | ( | void | ) |
Allocates an output buffer for an output interface. Used when we want the op_interface log_format to override the global_log_format. Currently not used.
buffer | Pointer to the newly created output_buffer |
Definition at line 666 of file util-debug.c.
References SCMalloc.
void SCLogAppendOPIfaceCtx | ( | SCLogOPIfaceCtx * | iface_ctx, |
SCLogInitData * | sc_lid | ||
) |
Appends an output_interface to the output_interface list sent in head.
iface_ctx | Pointer to the output_interface that has to be added to head |
head | Pointer to the output_interface list |
Definition at line 1209 of file util-debug.c.
References head, SCLogOPIfaceCtx_::next, SCLogInitData_::op_ifaces, and SCLogInitData_::op_ifaces_cnt.
int SCLogDebugEnabled | ( | void | ) |
Returns whether debug messages are enabled to be logged or not.
1 | if debug messages are enabled to be logged |
0 | if debug messages are not enabled to be logged |
Definition at line 647 of file util-debug.c.
References SC_LOG_DEBUG, and sc_log_global_log_level.
Referenced by DetectBytejumpDoMatch(), FlowVarPrint(), HtpBodyPrint(), and SMTPProcessDataChunk().
void SCLogDeInitLogModule | ( | void | ) |
De-Initializes the logging module.
Definition at line 1508 of file util-debug.c.
Referenced by SCLogInitLogModule().
void SCLogErr | ( | int | x, |
const char * | file, | ||
const char * | func, | ||
const int | line, | ||
const int | err, | ||
const char * | fmt, | ||
... | |||
) |
Definition at line 622 of file util-debug.c.
References msg, sc_log_fd_filters_present, sc_log_fg_filters_present, sc_log_global_log_level, SC_LOG_MAX_LOG_MSG_LEN, SCLogMatchFDFilter(), SCLogMatchFGFilterBL(), SCLogMatchFGFilterWL(), and SCLogMessage().
SCLogLevel SCLogGetLogLevel | ( | void | ) |
Definition at line 966 of file util-debug.c.
References sc_log_global_log_level.
void SCLogInitLogModule | ( | SCLogInitData * | sc_lid | ) |
Initializes the logging module.
sc_lid | The initialization data for the logging module. If sc_lid is NULL, we would stick to the default configuration for the logging subsystem. \initonly |
Definition at line 1294 of file util-debug.c.
References FatalError, SC_ERR_FATAL, SCLogDeInitLogModule(), and SCMutexInit.
Referenced by InitGlobal().
SCLogOPIfaceCtx* SCLogInitOPIfaceCtx | ( | const char * | iface_name, |
const char * | log_format, | ||
int | log_level, | ||
const char * | arg | ||
) |
Creates a new output interface based on the arguments sent. The kind of output interface to be created is decided by the iface_name arg. If iface_name is "file", the arg argument will hold the filename to be used for logging purposes. If iface_name is "syslog", the arg argument holds the facility code. If iface_name is "console", arg is NULL.
iface_name | Interface name. Can be "console", "file" or "syslog" |
log_format | Override for the global_log_format |
log_level | Override for the global_log_level |
log_level | Parameter required by a particular interface. Explained in the function description |
iface_ctx | Pointer to the newly created output interface |
Definition at line 1254 of file util-debug.c.
References SC_LOG_DEBUG, SC_LOG_NOTSET, SC_LOG_OP_IFACE_CONSOLE, sc_log_op_iface_map, and SCMapEnumNameToValue().
void SCLogLoadConfig | ( | int | daemon, |
int | verbose, | ||
uint32_t | userid, | ||
uint32_t | groupid | ||
) |
Definition at line 1327 of file util-debug.c.
References ConfGet(), ConfGetNode(), SCLogInitData_::global_log_format, SCLogInitData_::global_log_level, MAX, SC_ERR_INVALID_ARGUMENT, sc_log_level_map, SC_LOG_NOTICE, SCLogAllocLogInitData(), SCLogDebug, SCLogError, and SCMapEnumNameToValue().
Referenced by ListAppLayerProtocols(), and ListKeywords().
SCError SCLogMessage | ( | const SCLogLevel | log_level, |
const char * | file, | ||
const unsigned int | line, | ||
const char * | function, | ||
const SCError | error_code, | ||
const char * | message | ||
) |
Adds the global log_format to the outgoing buffer.
log_level | log_level of the message that has to be logged |
msg | Buffer containing the outgoing message |
file | File_name from where the message originated |
function | Function_name from where the message originated |
line | Line_no from where the messaged originated |
SC_OK | on success; else an error code |
Definition at line 526 of file util-debug.c.
References SC_LOG_MAX_LOG_MSG_LEN, sc_log_module_initialized, and SC_OK.
Referenced by InitGlobal(), SCLog(), and SCLogErr().
void SCLogRegisterTests | ( | ) |
Definition at line 1711 of file util-debug.c.
References UtRegisterTest().
SCLogLevel sc_log_global_log_level |
Holds the global log level. Is the same as sc_log_config->log_level.
Definition at line 95 of file util-debug.c.
Referenced by SCLog(), SCLogDebugEnabled(), SCLogErr(), and SCLogGetLogLevel().
SCEnumCharMap sc_log_level_map[] |
Definition at line 51 of file util-debug.c.
Referenced by SCLogLoadConfig().
int sc_log_module_cleaned = 0 |
Used to indicate whether the logging module has been cleaned or not.
Definition at line 105 of file util-debug.c.
int sc_log_module_initialized = 0 |
Used to indicate whether the logging module has been init or not.
Definition at line 100 of file util-debug.c.
Referenced by SCLogAddFDFilter(), SCLogCheckFDFilterEntry(), SCLogCheckFDFilterExit(), SCLogMatchFDFilter(), SCLogMessage(), SCLogPrintFDFilters(), SCLogPrintFGFilters(), and SCLogRemoveFDFilter().
SCEnumCharMap sc_log_op_iface_map[] |
Definition at line 68 of file util-debug.c.
Referenced by SCLogInitOPIfaceCtx().