suricata
util-debug.h File Reference
#include "suricata-common.h"
#include "threads.h"
#include "util-enum.h"
#include "util-error.h"
#include "util-debug-filters.h"
#include "util-atomic.h"
Include dependency graph for util-debug.h:

Go to the source code of this file.

Data Structures

struct  SCLogOPBuffer_
 Structure to be used when log_level override support would be provided by the logging module. More...
 
struct  SCLogOPIfaceCtx_
 The output interface context for the logging module. More...
 
struct  SCLogInitData_
 Structure containing init data, that would be passed to SCInitDebugModule() More...
 
struct  SCLogConfig_
 Holds the config state used by the logging api. More...
 

Macros

#define SC_LOG_ENV_LOG_LEVEL   "SC_LOG_LEVEL"
 ENV vars that can be used to set the properties for the logging module. More...
 
#define SC_LOG_ENV_LOG_OP_IFACE   "SC_LOG_OP_IFACE"
 
#define SC_LOG_ENV_LOG_FILE   "SC_LOG_FILE"
 
#define SC_LOG_ENV_LOG_FACILITY   "SC_LOG_FACILITY"
 
#define SC_LOG_ENV_LOG_FORMAT   "SC_LOG_FORMAT"
 
#define SC_LOG_ENV_LOG_OP_FILTER   "SC_LOG_OP_FILTER"
 
#define SC_LOG_DEF_LOG_FORMAT_REL   "%t - <%d> - "
 
#define SC_LOG_DEF_LOG_FORMAT_DEV   "[%i] %t - (%f:%l) <%d> (%n) -- "
 
#define SC_LOG_MAX_LOG_MSG_LEN   2048
 
#define SC_LOG_MAX_LOG_FORMAT_LEN   128
 
#define SC_LOG_DEF_LOG_LEVEL   SC_LOG_INFO
 
#define SC_LOG_DEF_LOG_OP_IFACE   SC_LOG_OP_IFACE_CONSOLE
 
#define SC_LOG_DEF_LOG_FILE   "suricata.log"
 
#define SC_LOG_DEF_SYSLOG_FACILITY_STR   "local0"
 
#define SC_LOG_DEF_SYSLOG_FACILITY   LOG_LOCAL0
 
#define SC_LOG_FMT_TIME   't' /* Timestamp in standard format */
 
#define SC_LOG_FMT_PID   'p' /* PID */
 
#define SC_LOG_FMT_TID   'i' /* Thread ID */
 
#define SC_LOG_FMT_TM   'm' /* Thread module name */
 
#define SC_LOG_FMT_LOG_LEVEL   'd' /* Log level */
 
#define SC_LOG_FMT_FILE_NAME   'f' /* File name */
 
#define SC_LOG_FMT_LINE   'l' /* Line number */
 
#define SC_LOG_FMT_FUNCTION   'n' /* Function */
 
#define SC_LOG_FMT_PREFIX   '%'
 
#define SCLogInfo(...)
 Macro used to log INFORMATIONAL messages. More...
 
#define SCLogInfoRaw(file, func, line, ...)
 
#define SCLogConfig(...)
 
#define SCLogPerf(...)
 
#define SCLogNotice(...)
 Macro used to log NOTICE messages. More...
 
#define SCLogNoticeRaw(file, func, line, ...)
 
#define SCLogWarning(err_code, ...)
 Macro used to log WARNING messages. More...
 
#define SCLogWarningRaw(err_code, file, func, line, ...)   SCLogErr(SC_LOG_WARNING, (file), (func), (line), err_code, __VA_ARGS__)
 
#define SCLogError(err_code, ...)
 Macro used to log ERROR messages. More...
 
#define SCLogErrorRaw(err_code, file, func, line, ...)
 
#define SCLogCritical(err_code, ...)
 Macro used to log CRITICAL messages. More...
 
#define SCLogAlert(err_code, ...)
 Macro used to log ALERT messages. More...
 
#define SCLogEmerg(err_code, ...)
 Macro used to log EMERGENCY messages. More...
 
#define SCLogDebug(...)   do { } while (0)
 
#define SCEnter(...)
 
#define SCReturn   return
 
#define SCReturnInt(x)   return x
 
#define SCReturnUInt(x)   return x
 
#define SCReturnDbl(x)   return x
 
#define SCReturnChar(x)   return x
 
#define SCReturnCharPtr(x)   return x
 
#define SCReturnCT(x, type)   return x
 
#define SCReturnPtr(x, type)   return x
 
#define SCReturnBool(x)   return x
 
#define SCReturnStruct(x)   return x
 
#define FatalError(x, ...)
 
#define FatalErrorOnInit(x, ...)
 Fatal error IF we're starting up, and configured to consider errors to be fatal errors. More...
 

Typedefs

typedef struct SCLogOPBuffer_ SCLogOPBuffer
 Structure to be used when log_level override support would be provided by the logging module. More...
 
typedef struct SCLogOPIfaceCtx_ SCLogOPIfaceCtx
 The output interface context for the logging module. More...
 
typedef struct SCLogInitData_ SCLogInitData
 Structure containing init data, that would be passed to SCInitDebugModule() More...
 
typedef struct SCLogConfig_ SCLogConfig
 Holds the config state used by the logging api. More...
 

Enumerations

enum  SCLogLevel {
  SC_LOG_NOTSET = -1, SC_LOG_NONE = 0, SC_LOG_EMERGENCY, SC_LOG_ALERT,
  SC_LOG_CRITICAL, SC_LOG_ERROR, SC_LOG_WARNING, SC_LOG_NOTICE,
  SC_LOG_INFO, SC_LOG_PERF, SC_LOG_CONFIG, SC_LOG_DEBUG,
  SC_LOG_LEVEL_MAX
}
 The various log levels NOTE: when adding new level, don't forget to update SCLogMapLogLevelToSyslogLevel() or it may result in logging to syslog with LOG_EMERG priority. More...
 
enum  SCLogOPIface { SC_LOG_OP_IFACE_CONSOLE, SC_LOG_OP_IFACE_FILE, SC_LOG_OP_IFACE_SYSLOG, SC_LOG_OP_IFACE_MAX }
 The various output interfaces supported. More...
 
enum  SCLogOPType { SC_LOG_OP_TYPE_REGULAR = 0, SC_LOG_OP_TYPE_JSON }
 

Functions

void SCLog (int x, const char *file, const char *func, const int line, const char *fmt,...) ATTR_FMT_PRINTF(5
 
void void SCLogErr (int x, const char *file, const char *func, const int line, const int err, const char *fmt,...) ATTR_FMT_PRINTF(6
 
SCLogInitDataSCLogAllocLogInitData (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...
 
SCLogOPIfaceCtxSCLogInitOPIfaceCtx (const char *, const char *, int, const char *)
 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 SCLogAppendOPIfaceCtx (SCLogOPIfaceCtx *, SCLogInitData *)
 Appends an output_interface to the output_interface list sent in head. More...
 
void SCLogInitLogModule (SCLogInitData *)
 Initializes the logging module. More...
 
void SCLogDeInitLogModule (void)
 De-Initializes the logging module. More...
 
SCError SCLogMessage (const SCLogLevel, const char *, const unsigned int, const char *, const SCError, const char *message)
 Adds the global log_format to the outgoing buffer. More...
 
SCLogOPBufferSCLogAllocLogOPBuffer (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...
 
int SCLogDebugEnabled (void)
 Returns whether debug messages are enabled to be logged or not. More...
 
void SCLogRegisterTests (void)
 
void SCLogLoadConfig (int daemon, int verbose)
 
SCLogLevel SCLogGetLogLevel (void)
 

Variables

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
 Used to indicate whether the logging module has been init or not. More...
 
int sc_log_module_cleaned
 Used to indicate whether the logging module has been cleaned or not. More...
 

Detailed Description

Macro Definition Documentation

◆ FatalError

#define FatalError (   x,
  ... 
)
Value:
do { \
SCLogError(x, __VA_ARGS__); \
exit(EXIT_FAILURE); \
} while(0)

Definition at line 533 of file util-debug.h.

◆ FatalErrorOnInit

#define FatalErrorOnInit (   x,
  ... 
)
Value:
do { \
SC_ATOMIC_EXTERN(unsigned int, engine_stage); \
int init_errors_fatal = 0; \
ConfGetBool("engine.init-failure-fatal", &init_errors_fatal); \
if (init_errors_fatal && (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT))\
{ \
SCLogError(x, __VA_ARGS__); \
exit(EXIT_FAILURE); \
} \
SCLogWarning(x, __VA_ARGS__); \
} while(0)

Fatal error IF we're starting up, and configured to consider errors to be fatal errors.

Definition at line 541 of file util-debug.h.

◆ SC_LOG_DEF_LOG_FILE

#define SC_LOG_DEF_LOG_FILE   "suricata.log"

Definition at line 99 of file util-debug.h.

◆ SC_LOG_DEF_LOG_FORMAT_DEV

#define SC_LOG_DEF_LOG_FORMAT_DEV   "[%i] %t - (%f:%l) <%d> (%n) -- "

Definition at line 84 of file util-debug.h.

◆ SC_LOG_DEF_LOG_FORMAT_REL

#define SC_LOG_DEF_LOG_FORMAT_REL   "%t - <%d> - "

Definition at line 83 of file util-debug.h.

◆ SC_LOG_DEF_LOG_LEVEL

#define SC_LOG_DEF_LOG_LEVEL   SC_LOG_INFO

Definition at line 93 of file util-debug.h.

◆ SC_LOG_DEF_LOG_OP_IFACE

#define SC_LOG_DEF_LOG_OP_IFACE   SC_LOG_OP_IFACE_CONSOLE

Definition at line 96 of file util-debug.h.

◆ SC_LOG_DEF_SYSLOG_FACILITY

#define SC_LOG_DEF_SYSLOG_FACILITY   LOG_LOCAL0

Definition at line 103 of file util-debug.h.

◆ SC_LOG_DEF_SYSLOG_FACILITY_STR

#define SC_LOG_DEF_SYSLOG_FACILITY_STR   "local0"

Definition at line 102 of file util-debug.h.

◆ SC_LOG_ENV_LOG_FACILITY

#define SC_LOG_ENV_LOG_FACILITY   "SC_LOG_FACILITY"

Definition at line 42 of file util-debug.h.

◆ SC_LOG_ENV_LOG_FILE

#define SC_LOG_ENV_LOG_FILE   "SC_LOG_FILE"

Definition at line 41 of file util-debug.h.

◆ SC_LOG_ENV_LOG_FORMAT

#define SC_LOG_ENV_LOG_FORMAT   "SC_LOG_FORMAT"

Definition at line 43 of file util-debug.h.

◆ SC_LOG_ENV_LOG_LEVEL

#define SC_LOG_ENV_LOG_LEVEL   "SC_LOG_LEVEL"

ENV vars that can be used to set the properties for the logging module.

Definition at line 39 of file util-debug.h.

◆ SC_LOG_ENV_LOG_OP_FILTER

#define SC_LOG_ENV_LOG_OP_FILTER   "SC_LOG_OP_FILTER"

Definition at line 44 of file util-debug.h.

◆ SC_LOG_ENV_LOG_OP_IFACE

#define SC_LOG_ENV_LOG_OP_IFACE   "SC_LOG_OP_IFACE"

Definition at line 40 of file util-debug.h.

◆ SC_LOG_FMT_FILE_NAME

#define SC_LOG_FMT_FILE_NAME   'f' /* File name */

Definition at line 195 of file util-debug.h.

◆ SC_LOG_FMT_FUNCTION

#define SC_LOG_FMT_FUNCTION   'n' /* Function */

Definition at line 197 of file util-debug.h.

◆ SC_LOG_FMT_LINE

#define SC_LOG_FMT_LINE   'l' /* Line number */

Definition at line 196 of file util-debug.h.

◆ SC_LOG_FMT_LOG_LEVEL

#define SC_LOG_FMT_LOG_LEVEL   'd' /* Log level */

Definition at line 194 of file util-debug.h.

◆ SC_LOG_FMT_PID

#define SC_LOG_FMT_PID   'p' /* PID */

Definition at line 191 of file util-debug.h.

◆ SC_LOG_FMT_PREFIX

#define SC_LOG_FMT_PREFIX   '%'

Definition at line 200 of file util-debug.h.

◆ SC_LOG_FMT_TID

#define SC_LOG_FMT_TID   'i' /* Thread ID */

Definition at line 192 of file util-debug.h.

◆ SC_LOG_FMT_TIME

#define SC_LOG_FMT_TIME   't' /* Timestamp in standard format */

Definition at line 190 of file util-debug.h.

◆ SC_LOG_FMT_TM

#define SC_LOG_FMT_TM   'm' /* Thread module name */

Definition at line 193 of file util-debug.h.

◆ SC_LOG_MAX_LOG_FORMAT_LEN

#define SC_LOG_MAX_LOG_FORMAT_LEN   128

Definition at line 90 of file util-debug.h.

◆ SC_LOG_MAX_LOG_MSG_LEN

#define SC_LOG_MAX_LOG_MSG_LEN   2048

Definition at line 87 of file util-debug.h.

◆ SCEnter

#define SCEnter (   ...)

Definition at line 301 of file util-debug.h.

◆ SCLogAlert

#define SCLogAlert (   err_code,
  ... 
)
Value:
__FILE__, __FUNCTION__, __LINE__, \
err_code, __VA_ARGS__)

Macro used to log ALERT messages.

Return values
err_codeError code that has to be logged along with the alert message
...Takes as argument(s), a printf style format message

Definition at line 281 of file util-debug.h.

◆ SCLogConfig

#define SCLogConfig (   ...)
Value:
__FILE__, __FUNCTION__, __LINE__, __VA_ARGS__)

Definition at line 223 of file util-debug.h.

◆ SCLogCritical

#define SCLogCritical (   err_code,
  ... 
)
Value:
__FILE__, __FUNCTION__, __LINE__, \
err_code, __VA_ARGS__)

Macro used to log CRITICAL messages.

Return values
err_codeError code that has to be logged along with the critical message
...Takes as argument(s), a printf style format message

Definition at line 271 of file util-debug.h.

◆ SCLogDebug

#define SCLogDebug (   ...)    do { } while (0)

Definition at line 299 of file util-debug.h.

◆ SCLogEmerg

#define SCLogEmerg (   err_code,
  ... 
)
Value:
__FILE__, __FUNCTION__, __LINE__, \
err_code, __VA_ARGS__)

Macro used to log EMERGENCY messages.

Return values
err_codeError code that has to be logged along with the emergency message
...Takes as argument(s), a printf style format message

Definition at line 291 of file util-debug.h.

◆ SCLogError

#define SCLogError (   err_code,
  ... 
)
Value:
__FILE__, __FUNCTION__, __LINE__, \
err_code, __VA_ARGS__)

Macro used to log ERROR messages.

Return values
err_codeError code that has to be logged along with the error message
...Takes as argument(s), a printf style format message

Definition at line 258 of file util-debug.h.

◆ SCLogErrorRaw

#define SCLogErrorRaw (   err_code,
  file,
  func,
  line,
  ... 
)
Value:
(file), (func), (line), err_code, __VA_ARGS__)

Definition at line 261 of file util-debug.h.

◆ SCLogInfo

#define SCLogInfo (   ...)
Value:
__FILE__, __FUNCTION__, __LINE__, __VA_ARGS__)

Macro used to log INFORMATIONAL messages.

Return values
...Takes as argument(s), a printf style format message

Definition at line 218 of file util-debug.h.

◆ SCLogInfoRaw

#define SCLogInfoRaw (   file,
  func,
  line,
  ... 
)
Value:
(file), (func), (line), __VA_ARGS__)

Definition at line 220 of file util-debug.h.

◆ SCLogNotice

#define SCLogNotice (   ...)
Value:
__FILE__, __FUNCTION__, __LINE__, __VA_ARGS__)

Macro used to log NOTICE messages.

Return values
...Takes as argument(s), a printf style format message

Definition at line 233 of file util-debug.h.

◆ SCLogNoticeRaw

#define SCLogNoticeRaw (   file,
  func,
  line,
  ... 
)
Value:
(file), (func), (line), __VA_ARGS__)

Definition at line 235 of file util-debug.h.

◆ SCLogPerf

#define SCLogPerf (   ...)
Value:
__FILE__, __FUNCTION__, __LINE__, __VA_ARGS__)

Definition at line 225 of file util-debug.h.

◆ SCLogWarning

#define SCLogWarning (   err_code,
  ... 
)
Value:
__FILE__, __FUNCTION__, __LINE__, \
err_code, __VA_ARGS__)

Macro used to log WARNING messages.

Return values
err_codeError code that has to be logged along with the warning message
...Takes as argument(s), a printf style format message

Definition at line 245 of file util-debug.h.

◆ SCLogWarningRaw

#define SCLogWarningRaw (   err_code,
  file,
  func,
  line,
  ... 
)    SCLogErr(SC_LOG_WARNING, (file), (func), (line), err_code, __VA_ARGS__)

Definition at line 248 of file util-debug.h.

◆ SCReturn

#define SCReturn   return

Definition at line 303 of file util-debug.h.

◆ SCReturnBool

#define SCReturnBool (   x)    return x

Definition at line 319 of file util-debug.h.

◆ SCReturnChar

#define SCReturnChar (   x)    return x

Definition at line 311 of file util-debug.h.

◆ SCReturnCharPtr

#define SCReturnCharPtr (   x)    return x

Definition at line 313 of file util-debug.h.

◆ SCReturnCT

#define SCReturnCT (   x,
  type 
)    return x

Definition at line 315 of file util-debug.h.

◆ SCReturnDbl

#define SCReturnDbl (   x)    return x

Definition at line 309 of file util-debug.h.

◆ SCReturnInt

#define SCReturnInt (   x)    return x

Definition at line 305 of file util-debug.h.

◆ SCReturnPtr

#define SCReturnPtr (   x,
  type 
)    return x

Definition at line 317 of file util-debug.h.

◆ SCReturnStruct

#define SCReturnStruct (   x)    return x

Definition at line 321 of file util-debug.h.

◆ SCReturnUInt

#define SCReturnUInt (   x)    return x

Definition at line 307 of file util-debug.h.

Typedef Documentation

◆ SCLogConfig

typedef struct SCLogConfig_ SCLogConfig

Holds the config state used by the logging api.

◆ SCLogInitData

typedef struct SCLogInitData_ SCLogInitData

Structure containing init data, that would be passed to SCInitDebugModule()

◆ SCLogOPBuffer

typedef struct SCLogOPBuffer_ SCLogOPBuffer

Structure to be used when log_level override support would be provided by the logging module.

◆ SCLogOPIfaceCtx

The output interface context for the logging module.

Enumeration Type Documentation

◆ SCLogLevel

enum SCLogLevel

The various log levels NOTE: when adding new level, don't forget to update SCLogMapLogLevelToSyslogLevel() or it may result in logging to syslog with LOG_EMERG priority.

Enumerator
SC_LOG_NOTSET 
SC_LOG_NONE 
SC_LOG_EMERGENCY 
SC_LOG_ALERT 
SC_LOG_CRITICAL 
SC_LOG_ERROR 
SC_LOG_WARNING 
SC_LOG_NOTICE 
SC_LOG_INFO 
SC_LOG_PERF 
SC_LOG_CONFIG 
SC_LOG_DEBUG 
SC_LOG_LEVEL_MAX 

Definition at line 50 of file util-debug.h.

◆ SCLogOPIface

The various output interfaces supported.

Enumerator
SC_LOG_OP_IFACE_CONSOLE 
SC_LOG_OP_IFACE_FILE 
SC_LOG_OP_IFACE_SYSLOG 
SC_LOG_OP_IFACE_MAX 

Definition at line 69 of file util-debug.h.

◆ SCLogOPType

Enumerator
SC_LOG_OP_TYPE_REGULAR 
SC_LOG_OP_TYPE_JSON 

Definition at line 76 of file util-debug.h.

Function Documentation

◆ SCLog()

void SCLog ( int  x,
const char *  file,
const char *  func,
const int  line,
const char *  fmt,
  ... 
)

◆ SCLogAllocLogInitData()

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.

Return values
sc_lidPointer to the newly created SCLogInitData \initonly

Definition at line 1156 of file util-debug.c.

References SCMalloc.

Referenced by SCLogLoadConfig().

Here is the caller graph for this function:

◆ SCLogAllocLogOPBuffer()

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.

Return values
bufferPointer to the newly created output_buffer

Definition at line 681 of file util-debug.c.

References SCMalloc.

◆ SCLogAppendOPIfaceCtx()

void SCLogAppendOPIfaceCtx ( SCLogOPIfaceCtx iface_ctx,
SCLogInitData sc_lid 
)

Appends an output_interface to the output_interface list sent in head.

Parameters
iface_ctxPointer to the output_interface that has to be added to head
headPointer to the output_interface list

Definition at line 1219 of file util-debug.c.

References head, SCLogOPIfaceCtx_::next, SCLogInitData_::op_ifaces, and SCLogInitData_::op_ifaces_cnt.

◆ SCLogDebugEnabled()

int SCLogDebugEnabled ( void  )

Returns whether debug messages are enabled to be logged or not.

Return values
1if debug messages are enabled to be logged
0if debug messages are not enabled to be logged

Definition at line 662 of file util-debug.c.

References SC_LOG_DEBUG, and sc_log_global_log_level.

Referenced by DetectBytejumpDoMatch(), FlowVarPrint(), HtpBodyPrint(), and SMTPProcessDataChunk().

Here is the caller graph for this function:

◆ SCLogDeInitLogModule()

void SCLogDeInitLogModule ( void  )

De-Initializes the logging module.

Definition at line 1518 of file util-debug.c.

Referenced by SCLogInitLogModule().

Here is the caller graph for this function:

◆ SCLogErr()

void void SCLogErr ( int  x,
const char *  file,
const char *  func,
const int  line,
const int  err,
const char *  fmt,
  ... 
)

◆ SCLogGetLogLevel()

SCLogLevel SCLogGetLogLevel ( void  )

Definition at line 974 of file util-debug.c.

References sc_log_global_log_level.

◆ SCLogInitLogModule()

void SCLogInitLogModule ( SCLogInitData sc_lid)

Initializes the logging module.

Parameters
sc_lidThe 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 1304 of file util-debug.c.

References FatalError, SC_ERR_FATAL, SCLogDeInitLogModule(), and SCMutexInit.

Referenced by InitGlobal().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SCLogInitOPIfaceCtx()

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.

Parameters
iface_nameInterface name. Can be "console", "file" or "syslog"
log_formatOverride for the global_log_format
log_levelOverride for the global_log_level
log_levelParameter required by a particular interface. Explained in the function description
Return values
iface_ctxPointer to the newly created output interface

Definition at line 1264 of file util-debug.c.

References SC_LOG_DEBUG, SC_LOG_NOTSET, SC_LOG_OP_IFACE_CONSOLE, sc_log_op_iface_map, and SCMapEnumNameToValue().

Here is the call graph for this function:

◆ SCLogLoadConfig()

void SCLogLoadConfig ( int  daemon,
int  verbose 
)

Definition at line 1337 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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SCLogMessage()

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.

Parameters
log_levellog_level of the message that has to be logged
msgBuffer containing the outgoing message
fileFile_name from where the message originated
functionFunction_name from where the message originated
lineLine_no from where the messaged originated
Return values
SC_OKon success; else an error code

Definition at line 541 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().

Here is the caller graph for this function:

◆ SCLogRegisterTests()

void SCLogRegisterTests ( void  )

Definition at line 1721 of file util-debug.c.

References UtRegisterTest().

Here is the call graph for this function:

Variable Documentation

◆ sc_log_global_log_level

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().

◆ sc_log_module_cleaned

int sc_log_module_cleaned

Used to indicate whether the logging module has been cleaned or not.

Definition at line 105 of file util-debug.c.

◆ sc_log_module_initialized

int sc_log_module_initialized

Used to indicate whether the logging module has been init or not.

Definition at line 100 of file util-debug.c.

Referenced by SCLogMessage().

SC_LOG_CONFIG
@ SC_LOG_CONFIG
Definition: util-debug.h:61
SCLogErr
void void SCLogErr(int x, const char *file, const char *func, const int line, const int err, const char *fmt,...) ATTR_FMT_PRINTF(6
SURICATA_INIT
@ SURICATA_INIT
Definition: suricata.h:96
SC_LOG_NOTICE
@ SC_LOG_NOTICE
Definition: util-debug.h:58
SCLog
void SCLog(int x, const char *file, const char *func, const int line, const char *fmt,...) ATTR_FMT_PRINTF(5
SC_LOG_INFO
@ SC_LOG_INFO
Definition: util-debug.h:59
SC_LOG_ERROR
@ SC_LOG_ERROR
Definition: util-debug.h:56
SC_LOG_WARNING
@ SC_LOG_WARNING
Definition: util-debug.h:57
SC_LOG_ALERT
@ SC_LOG_ALERT
Definition: util-debug.h:54
SC_LOG_CRITICAL
@ SC_LOG_CRITICAL
Definition: util-debug.h:55
SC_LOG_PERF
@ SC_LOG_PERF
Definition: util-debug.h:60
SC_ATOMIC_GET
#define SC_ATOMIC_GET(name)
Get the value from the atomic variable.
Definition: util-atomic.h:376
SC_LOG_EMERGENCY
@ SC_LOG_EMERGENCY
Definition: util-debug.h:53