|
suricata
|
#include "suricata-common.h"#include "util-debug.h"#include "output.h"#include "suricata.h"#include "util-conf.h"#include "util-enum.h"#include "util-path.h"#include "util-syslog.h"#include "util-time.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 char *module, const char *message) |
| Adds the global log_format to the outgoing buffer. | |
| void | SCLog (int x, const char *file, const char *func, const int line, const char *module, const char *fmt,...) |
| void | SCLogErr (int x, const char *file, const char *func, const int line, const char *module, const char *fmt,...) |
| int | SCLogDebugEnabled (void) |
| Returns whether debug messages are enabled to be logged or not. | |
| 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. | |
| 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 parameters are read from the conf file. | |
| void | SCLogAppendOPIfaceCtx (SCLogOPIfaceCtx *iface_ctx, SCLogInitData *sc_lid) |
| Appends an output_interface to the output_interface list sent in head. | |
| void | SCLogInitLogModule (SCLogInitData *sc_lid) |
| Initializes the logging module. | |
| void | SCLogLoadConfig (int daemon, int verbose, uint32_t userid, uint32_t groupid) |
| void | SCLogDeInitLogModule (void) |
| De-Initializes the logging module. | |
| void | SCFatalErrorOnInitStatic (const char *arg) |
| void | SCLogRegisterTests (void) |
Variables | |
| SCEnumCharMap | sc_log_level_map [] |
| SCEnumCharMap | sc_log_slevel_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. | |
| int | sc_log_module_initialized = 0 |
| Used to indicate whether the logging module has been init or not. | |
| int | sc_log_module_cleaned = 0 |
| Used to indicate whether the logging module has been cleaned or not. | |
Debug utility functions
Definition in file util-debug.c.
| void SCFatalErrorOnInitStatic | ( | const char * | arg | ) |
Definition at line 1614 of file util-debug.c.
References FatalErrorOnInit.
| void SCLog | ( | int | x, |
| const char * | file, | ||
| const char * | func, | ||
| const int | line, | ||
| const char * | module, | ||
| const char * | fmt, | ||
| ... | |||
| ) |
Definition at line 723 of file util-debug.c.
References 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().

| SCLogInitData * SCLogAllocLogInitData | ( | void | ) |
Returns a pointer to a new SCLogInitData. This is a public interface intended to be used after the logging parameters are read from the conf file.
| sc_lid | Pointer to the newly created SCLogInitData \initonly |
Definition at line 1250 of file util-debug.c.
References SCCalloc.
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 786 of file util-debug.c.
References FatalError, SCLogOPBuffer_::log_format, SCLogOPIfaceCtx_::log_format, SCLogOPBuffer_::msg, SCLogOPIfaceCtx_::next, SCLogConfig_::op_ifaces, SCLogConfig_::op_ifaces_cnt, SCMalloc, and SCLogOPBuffer_::temp.
| 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 1306 of file util-debug.c.
References head, SCLogOPIfaceCtx_::next, SCLogInitData_::op_ifaces, and SCLogInitData_::op_ifaces_cnt.
Referenced by SCLogLoadConfig().

| 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 767 of file util-debug.c.
References SC_LOG_DEBUG, and sc_log_global_log_level.
Referenced by AppLayerProtoDetectPrepareState(), DecodeIPV4(), DecodeIPV6(), DecodeNSH(), DetectBytejumpDoMatch(), DetectPortInsert(), FlowVarPrint(), SigPrepareStage1(), SRepLoadFileFromFD(), and StreamTcpReassembleInsertSegment().

| void SCLogDeInitLogModule | ( | void | ) |
De-Initializes the logging module.
Definition at line 1594 of file util-debug.c.
References sc_log_global_log_level, sc_log_module_cleaned, sc_log_module_initialized, SCLogReleaseFDFilters(), SCLogReleaseFGFilters(), and SCMutexDestroy.
Referenced by GlobalsDestroy(), and SCLogInitLogModule().


| void SCLogErr | ( | int | x, |
| const char * | file, | ||
| const char * | func, | ||
| const int | line, | ||
| const char * | module, | ||
| const char * | fmt, | ||
| ... | |||
| ) |
Definition at line 742 of file util-debug.c.
References 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 1070 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 1390 of file util-debug.c.
References FatalError, sc_log_global_log_level, sc_log_module_cleaned, sc_log_module_initialized, SCCalloc, SCLogDeInitLogModule(), and SCMutexInit.
Referenced by InitGlobal(), and SCLogLoadConfig().


| void SCLogLoadConfig | ( | int | daemon, |
| int | verbose, | ||
| uint32_t | userid, | ||
| uint32_t | groupid | ||
| ) |
Definition at line 1420 of file util-debug.c.
References FatalError, SCLogInitData_::global_log_format, SCLogInitData_::global_log_level, SCLogConfig_::log_format, MAX, SCConfNode_::name, next, SCLogInitData_::op_filter, SCLogConfig_::op_filter, PathIsAbsolute(), SC_LOG_DEF_FILE_FORMAT, SC_LOG_DEF_SYSLOG_FACILITY, SC_LOG_DEF_SYSLOG_FACILITY_STR, sc_log_global_log_level, sc_log_level_map, SC_LOG_NOTICE, SC_LOG_OP_TYPE_JSON, SC_LOG_OP_TYPE_REGULAR, SCConfGet(), SCConfGetNode(), SCConfNodeLookupChild(), SCConfNodeLookupChildValue(), SCConfValIsFalse(), SCFree, SCLogAllocLogInitData(), SCLogAppendOPIfaceCtx(), SCLogDebug, SCLogError, SCLogInitLogModule(), SCLogWarning, SCMapEnumNameToValue(), SCStrdup, SCSyslogGetFacilityMap(), TAILQ_FOREACH, type, and SCConfNode_::val.
Referenced by ListAppLayerHooks(), ListAppLayerProtocols(), ListKeywords(), and SuricataInit().


| SCError SCLogMessage | ( | const SCLogLevel | log_level, |
| const char * | file, | ||
| const unsigned int | line, | ||
| const char * | function, | ||
| const char * | module, | ||
| 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 652 of file util-debug.c.
References SCLogOPIfaceCtx_::file, SCLogOPIfaceCtx_::file_d, SCLogOPIfaceCtx_::fp_mutex, SCLogOPIfaceCtx_::iface, SCLogOPIfaceCtx_::log_format, SCLogConfig_::log_format, SCLogOPIfaceCtx_::log_level, SCLogOPIfaceCtx_::next, SCLogConfig_::op_ifaces, SCLogOPIfaceCtx_::rotation_flag, SC_LOG_ERROR, SC_LOG_MAX_LOG_MSG_LEN, sc_log_module_initialized, SC_LOG_NOTSET, SC_LOG_OP_IFACE_CONSOLE, SC_LOG_OP_IFACE_FILE, SC_LOG_OP_IFACE_SYSLOG, SC_OK, SCLogError, SCMutexLock, SCMutexUnlock, SCTIME_FROM_TIMEVAL, ts, SCLogOPIfaceCtx_::type, and SCLogOPIfaceCtx_::use_color.
Referenced by SCLog(), and SCLogErr().

| void SCLogRegisterTests | ( | void | ) |
Definition at line 1801 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 101 of file util-debug.c.
Referenced by LogFileEnsureExists(), SCLog(), SCLogDebugEnabled(), SCLogDeInitLogModule(), SCLogErr(), SCLogGetLogLevel(), SCLogInitLogModule(), and SCLogLoadConfig().
| SCEnumCharMap sc_log_level_map[] |
Definition at line 41 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 111 of file util-debug.c.
Referenced by SCLogDeInitLogModule(), and SCLogInitLogModule().
| int sc_log_module_initialized = 0 |
Used to indicate whether the logging module has been init or not.
Definition at line 106 of file util-debug.c.
Referenced by SCLogAddFDFilter(), SCLogCheckFDFilterEntry(), SCLogCheckFDFilterExit(), SCLogDeInitLogModule(), SCLogInitLogModule(), SCLogMatchFDFilter(), SCLogMessage(), SCLogPrintFDFilters(), SCLogPrintFGFilters(), and SCLogRemoveFDFilter().
| SCEnumCharMap sc_log_op_iface_map[] |
Definition at line 68 of file util-debug.c.
| SCEnumCharMap sc_log_slevel_map[] |
Definition at line 54 of file util-debug.c.