suricata
util-debug.h
Go to the documentation of this file.
1 /* Copyright (C) 2007-2022 Open Information Security Foundation
2  *
3  * You can copy, redistribute or modify this Program under the terms of
4  * the GNU General Public License version 2 as published by the Free
5  * Software Foundation.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * version 2 along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15  * 02110-1301, USA.
16  */
17 
18 /**
19  * \file
20  *
21  * \author Anoop Saldanha <anoopsaldanha@gmail.com>
22  */
23 
24 #ifndef SURICATA_UTIL_DEBUG_H
25 #define SURICATA_UTIL_DEBUG_H
26 
27 #include "util-error.h"
28 
29 /**
30  * \brief The various log levels
31  * NOTE: when adding new level, don't forget to update SCLogMapLogLevelToSyslogLevel()
32  * or it may result in logging to syslog with LOG_EMERG priority.
33  */
34 typedef enum {
45 } SCLogLevel;
46 
47 SCError SCLogMessage(const SCLogLevel, const char *, const unsigned int, const char *, const char *,
48  const char *message);
49 
50 #ifndef SURICATA_BINDGEN_H
51 #include "suricata-common.h"
52 
53 #include "threads.h"
54 #include "util-debug-filters.h"
55 
56 /**
57  * \brief ENV vars that can be used to set the properties for the logging module
58  */
59 #define SC_LOG_ENV_LOG_LEVEL "SC_LOG_LEVEL"
60 #define SC_LOG_ENV_LOG_OP_IFACE "SC_LOG_OP_IFACE"
61 #define SC_LOG_ENV_LOG_FILE "SC_LOG_FILE"
62 #define SC_LOG_ENV_LOG_FACILITY "SC_LOG_FACILITY"
63 #define SC_LOG_ENV_LOG_FORMAT "SC_LOG_FORMAT"
64 #define SC_LOG_ENV_LOG_OP_FILTER "SC_LOG_OP_FILTER"
65 
66 /**
67  * \brief The various output interfaces supported
68  */
69 typedef enum {
74 } SCLogOPIface;
75 
76 typedef enum {
79 } SCLogOPType;
80 
81 /* The default log_format, if it is not supplied by the user */
82 #define SC_LOG_DEF_FILE_FORMAT "[%i - %m] %z %d: %S: %M"
83 #define SC_LOG_DEF_LOG_FORMAT_REL_NOTICE "%D: %S: %M"
84 #define SC_LOG_DEF_LOG_FORMAT_REL_INFO "%d: %S: %M"
85 #define SC_LOG_DEF_LOG_FORMAT_REL_CONFIG "[%i] %d: %S: %M"
86 #define SC_LOG_DEF_LOG_FORMAT_DEBUG "%d: %S: %M [%n:%f:%l]"
87 
88 /* The maximum length of the log message: we add max rule size and other info */
89 #define SC_LOG_MAX_LOG_MSG_LEN 8192 + PATH_MAX + 512
90 
91 /* The maximum length of the log format */
92 #define SC_LOG_MAX_LOG_FORMAT_LEN 128
93 
94 /* The default log level, if it is not supplied by the user */
95 #define SC_LOG_DEF_LOG_LEVEL SC_LOG_INFO
96 
97 /* The default output interface to be used */
98 #define SC_LOG_DEF_LOG_OP_IFACE SC_LOG_OP_IFACE_CONSOLE
99 
100 /* The default log file to be used */
101 #define SC_LOG_DEF_LOG_FILE "suricata.log"
102 
103 /* The default syslog facility to be used */
104 #define SC_LOG_DEF_SYSLOG_FACILITY_STR "local0"
105 #define SC_LOG_DEF_SYSLOG_FACILITY LOG_LOCAL0
106 
107 /**
108  * \brief Structure to be used when log_level override support would be provided
109  * by the logging module
110  */
111 typedef struct SCLogOPBuffer_ {
113  char *temp;
114  const char *log_format;
116 
117 /**
118  * \brief The output interface context for the logging module
119  */
120 typedef struct SCLogOPIfaceCtx_ {
122 
123  bool use_color;
125 
126  /* the output file to be used if the interface is SC_LOG_IFACE_FILE */
127  const char *file;
128  /* the output file descriptor for the above file */
129  FILE * file_d;
130 
131  /* registered to be set on a file rotation signal */
133 
134  /* the facility code if the interface is SC_LOG_IFACE_SYSLOG */
135  int facility;
136 
137  /* override for the global_log_level */
139 
140  /* override for the global_log_format(currently not used) */
141  const char *log_format;
142 
143  /* Mutex used for locking around rotate/write to a file. */
145 
148 
149 /**
150  * \brief Structure containing init data, that would be passed to
151  * SCInitDebugModule()
152  */
153 typedef struct SCLogInitData_ {
154  /* startup message */
155  const char *startup_message;
156 
157  /* the log level */
159 
160  /* the log format */
161  const char *global_log_format;
162 
163  /* output filter */
164  const char *op_filter;
165 
166  /* list of output interfaces to be used */
168  /* no of op ifaces */
169  uint8_t op_ifaces_cnt;
171 
172 /**
173  * \brief Holds the config state used by the logging api
174  */
175 typedef struct SCLogConfig_ {
178  char *log_format;
179 
180  char *op_filter;
181  /* compiled pcre filter expression */
182  pcre2_code *op_filter_regex;
183  pcre2_match_data *op_filter_regex_match;
184 
185  /* op ifaces used */
187  /* no of op ifaces */
188  uint8_t op_ifaces_cnt;
190 
191 /* The different log format specifiers supported by the API */
192 #define SC_LOG_FMT_TIME 'z' /* Timestamp in RFC3339 like format */
193 #define SC_LOG_FMT_TIME_LEGACY 't' /* Timestamp in legacy format */
194 #define SC_LOG_FMT_PID 'p' /* PID */
195 #define SC_LOG_FMT_TID 'i' /* Thread ID */
196 #define SC_LOG_FMT_TM 'm' /* Thread module name */
197 #define SC_LOG_FMT_LOG_LEVEL 'd' /* Log level */
198 #define SC_LOG_FMT_LOG_SLEVEL 'D' /* Log level */
199 #define SC_LOG_FMT_FILE_NAME 'f' /* File name */
200 #define SC_LOG_FMT_LINE 'l' /* Line number */
201 #define SC_LOG_FMT_FUNCTION 'n' /* Function */
202 #define SC_LOG_FMT_SUBSYSTEM 'S' /* Subsystem name */
203 #define SC_LOG_FMT_THREAD_NAME 'T' /* thread name */
204 #define SC_LOG_FMT_MESSAGE 'M' /* log message body */
205 
206 /* The log format prefix for the format specifiers */
207 #define SC_LOG_FMT_PREFIX '%'
208 
209 /* Module and thread tagging */
210 /* The module name, usually the containing source-module name */
211 static const char *_sc_module __attribute__((unused)) = __SCFILENAME__;
212 
214 
215 extern int sc_log_module_initialized;
216 
217 extern int sc_log_module_cleaned;
218 
219 void SCLog(int x, const char *file, const char *func, const int line, const char *module,
220  const char *fmt, ...) ATTR_FMT_PRINTF(6, 7);
221 void SCLogErr(int x, const char *file, const char *func, const int line, const char *module,
222  const char *fmt, ...) ATTR_FMT_PRINTF(6, 7);
223 
224 /**
225  * \brief Macro used to log INFORMATIONAL messages.
226  *
227  * \retval ... Takes as argument(s), a printf style format message
228  */
229 #define SCLogInfo(...) SCLog(SC_LOG_INFO, __FILE__, __FUNCTION__, __LINE__, _sc_module, __VA_ARGS__)
230 #define SCLogInfoRaw(file, func, line, ...) \
231  SCLog(SC_LOG_INFO, (file), (func), (line), _sc_module, __VA_ARGS__)
232 
233 #define SCLogConfig(...) \
234  SCLog(SC_LOG_CONFIG, __FILE__, __FUNCTION__, __LINE__, _sc_module, __VA_ARGS__)
235 #define SCLogConfigRaw(file, func, line, ...) \
236  SCLog(SC_LOG_CONFIG, (file), (func), (line), _sc_module, __VA_ARGS__)
237 
238 #define SCLogPerf(...) SCLog(SC_LOG_PERF, __FILE__, __FUNCTION__, __LINE__, _sc_module, __VA_ARGS__)
239 #define SCLogPerfRaw(file, func, line, ...) \
240  SCLog(SC_LOG_PERF, (file), (func), (line), _sc_module, __VA_ARGS__)
241 
242 /**
243  * \brief Macro used to log NOTICE messages.
244  *
245  * \retval ... Takes as argument(s), a printf style format message
246  */
247 #define SCLogNotice(...) \
248  SCLog(SC_LOG_NOTICE, __FILE__, __FUNCTION__, __LINE__, _sc_module, __VA_ARGS__)
249 #define SCLogNoticeRaw(file, func, line, ...) \
250  SCLog(SC_LOG_NOTICE, (file), (func), (line), _sc_module, __VA_ARGS__)
251 
252 /**
253  * \brief Macro used to log WARNING messages.
254  *
255  * \retval err_code Error code that has to be logged along with the
256  * warning message
257  * \retval ... Takes as argument(s), a printf style format message
258  */
259 #define SCLogWarning(...) \
260  SCLogErr(SC_LOG_WARNING, __FILE__, __FUNCTION__, __LINE__, _sc_module, __VA_ARGS__)
261 #define SCLogWarningRaw(file, func, line, ...) \
262  SCLogErr(SC_LOG_WARNING, (file), (func), (line), _sc_module, __VA_ARGS__)
263 
264 /**
265  * \brief Macro used to log ERROR messages.
266  *
267  * \retval err_code Error code that has to be logged along with the
268  * error message
269  * \retval ... Takes as argument(s), a printf style format message
270  */
271 #define SCLogError(...) \
272  SCLogErr(SC_LOG_ERROR, __FILE__, __FUNCTION__, __LINE__, _sc_module, __VA_ARGS__)
273 #define SCLogErrorRaw(file, func, line, ...) \
274  SCLogErr(SC_LOG_ERROR, (file), (func), (line), _sc_module, __VA_ARGS__)
275 
276 /* Avoid the overhead of using the debugging subsystem, in production mode */
277 #ifndef DEBUG
278 
279 #define SCLogDebug(...) do { } while (0)
280 
281 #define SCEnter(...)
282 
283 #define SCReturn return
284 
285 #define SCReturnInt(x) return x
286 
287 #define SCReturnUInt(x) return x
288 
289 #define SCReturnDbl(x) return x
290 
291 #define SCReturnChar(x) return x
292 
293 #define SCReturnCharPtr(x) return x
294 
295 #define SCReturnCT(x, type) return x
296 
297 #define SCReturnPtr(x, type) return x
298 
299 #define SCReturnBool(x) return x
300 
301 #define SCReturnStruct(x) return x
302 
303 /* Please use it only for debugging purposes */
304 #else
305 
306 
307 /**
308  * \brief Macro used to log DEBUG messages. Comes under the debugging subsystem,
309  * and hence will be enabled only in the presence of the DEBUG macro.
310  *
311  * \retval ... Takes as argument(s), a printf style format message
312  */
313 #define SCLogDebug(...) \
314  SCLog(SC_LOG_DEBUG, __FILE__, __FUNCTION__, __LINE__, _sc_module, __VA_ARGS__)
315 #define SCLogDebugRaw(file, func, line, ...) \
316  SCLog(SC_LOG_DEBUG, (file), (func), (line), _sc_module, __VA_ARGS__)
317 
318 /**
319  * \brief Macro used to log debug messages on function entry. Comes under the
320  * debugging subsystem, and hence will be enabled only in the presence
321  * of the DEBUG macro. Apart from logging function_entry logs, it also
322  * processes the FD filters, if any FD filters are registered.
323  *
324  * \retval f An argument can be supplied, although it is not used
325  */
326 #define SCEnter(f) do { \
327  if (sc_log_global_log_level >= SC_LOG_DEBUG &&\
328  SCLogCheckFDFilterEntry(__FUNCTION__)) \
329  { \
330  SCLogDebug("Entering ... >>"); \
331  } \
332  } while(0)
333 
334 /**
335  * \brief Macro used to log debug messages on function exit. Comes under the
336  * debugging subsystem, and hence will be enabled only in the presence
337  * of the DEBUG macro. Apart from logging function_exit logs, it also
338  * processes the FD filters, if any FD filters are registered. This
339  * function_exit macro should be used for functions that don't return
340  * a value.
341  */
342 #define SCReturn do { \
343  if (sc_log_global_log_level >= SC_LOG_DEBUG) { \
344  SCLogDebug("Returning ... <<" ); \
345  SCLogCheckFDFilterExit(__FUNCTION__); \
346  } \
347  return; \
348  } while(0)
349 
350 /**
351  * \brief Macro used to log debug messages on function exit. Comes under the
352  * debugging subsystem, and hence will be enabled only in the presence
353  * of the DEBUG macro. Apart from logging function_exit logs, it also
354  * processes the FD filters, if any FD filters are registered. This
355  * function_exit macro should be used for functions that returns an
356  * integer value.
357  *
358  * \retval x Variable of type 'integer' that has to be returned
359  */
360 #define SCReturnInt(x) do { \
361  if (sc_log_global_log_level >= SC_LOG_DEBUG) { \
362  SCLogDebug("Returning: %"PRIdMAX" ... <<", (intmax_t)x); \
363  SCLogCheckFDFilterExit(__FUNCTION__); \
364  } \
365  return x; \
366  } while(0)
367 
368 /**
369  * \brief Macro used to log debug messages on function exit. Comes under the
370  * debugging subsystem, and hence will be enabled only in the presence
371  * of the DEBUG macro. Apart from logging function_exit logs, it also
372  * processes the FD filters, if any FD filters are registered. This
373  * function_exit macro should be used for functions that returns an
374  * unsigned integer value.
375  *
376  * \retval x Variable of type 'unsigned integer' that has to be returned
377  */
378 #define SCReturnUInt(x) do { \
379  if (sc_log_global_log_level >= SC_LOG_DEBUG) { \
380  SCLogDebug("Returning: %"PRIuMAX" ... <<", (uintmax_t)x); \
381  SCLogCheckFDFilterExit(__FUNCTION__); \
382  } \
383  return x; \
384  } while(0)
385 
386 /**
387  * \brief Macro used to log debug messages on function exit. Comes under the
388  * debugging subsystem, and hence will be enabled only in the presence
389  * of the DEBUG macro. Apart from logging function_exit logs, it also
390  * processes the FD filters, if any FD filters are registered. This
391  * function_exit macro should be used for functions that returns a
392  * float/double value.
393  *
394  * \retval x Variable of type 'float/double' that has to be returned
395  */
396 #define SCReturnDbl(x) do { \
397  if (sc_log_global_log_level >= SC_LOG_DEBUG) { \
398  SCLogDebug("Returning: %f ... <<", x); \
399  SCLogCheckFDFilterExit(__FUNCTION__); \
400  } \
401  return x; \
402  } while(0)
403 
404 /**
405  * \brief Macro used to log debug messages on function exit. Comes under the
406  * debugging subsystem, and hence will be enabled only in the presence
407  * of the DEBUG macro. Apart from logging function_exit logs, it also
408  * processes the FD filters, if any FD filters are registered. This
409  * function_exit macro should be used for functions that returns a var
410  * of character type.
411  *
412  * \retval x Variable of type 'char' that has to be returned
413  */
414 #define SCReturnChar(x) do { \
415  if (sc_log_global_log_level >= SC_LOG_DEBUG) { \
416  SCLogDebug("Returning: %c ... <<", x); \
417  SCLogCheckFDFilterExit(__FUNCTION__); \
418  } \
419  return x; \
420  } while(0)
421 
422 /**
423  * \brief Macro used to log debug messages on function exit. Comes under the
424  * debugging subsystem, and hence will be enabled only in the presence
425  * of the DEBUG macro. Apart from logging function_exit logs, it also
426  * processes the FD filters, if any FD filters are registered. This
427  * function_exit macro should be used for functions that returns a
428  * character string.
429  *
430  * \retval x Pointer to the char string that has to be returned
431  */
432 #define SCReturnCharPtr(x) do { \
433  if (sc_log_global_log_level >= SC_LOG_DEBUG) { \
434  if ((x) != NULL) { \
435  SCLogDebug("Returning: %s ... <<", x); \
436  } else { \
437  SCLogDebug("Returning: NULL ... <<"); \
438  } SCLogCheckFDFilterExit(__FUNCTION__); \
439  } \
440  return x; \
441  } while(0)
442 
443 /**
444  * \brief Macro used to log debug messages on function exit. Comes under the
445  * debugging subsystem, and hence will be enabled only in the presence
446  * of the DEBUG macro. Apart from logging function_exit logs, it also
447  * processes the FD filters, if any FD filters are registered. This
448  * function_exit macro should be used for functions that returns a var
449  * of custom type
450  *
451  * \retval x Variable instance of a custom type that has to be returned
452  * \retval type Pointer to a character string holding the name of the custom
453  * type(the argument x) that has to be returned
454  */
455 #define SCReturnCT(x, type) do { \
456  if (sc_log_global_log_level >= SC_LOG_DEBUG) { \
457  SCLogDebug("Returning var of " \
458  "type %s ... <<", type); \
459  SCLogCheckFDFilterExit(__FUNCTION__); \
460  } \
461  return x; \
462  } while(0)
463 
464 /**
465  * \brief Macro used to log debug messages on function exit. Comes under the
466  * debugging subsystem, and hence will be enabled only in the presence
467  * of the DEBUG macro. Apart from logging function_exit logs, it also
468  * processes the FD filters, if any FD filters are registered. This
469  * function_exit macro should be used for functions that returns a
470  * pointer to a custom type
471  *
472  * \retval x Pointer to a variable instance of a custom type that has to be
473  * returned
474  * \retval type Pointer to a character string holding the name of the custom
475  * type(the argument x) that has to be returned
476  */
477 #define SCReturnPtr(x, type) do { \
478  if (sc_log_global_log_level >= SC_LOG_DEBUG) { \
479  SCLogDebug("Returning pointer %p of " \
480  "type %s ... <<", x, type); \
481  SCLogCheckFDFilterExit(__FUNCTION__); \
482  } \
483  return x; \
484  } while(0)
485 
486 /**
487  * \brief Macro used to log debug messages on function exit. Comes under the
488  * debugging subsystem, and hence will be enabled only in the presence
489  * of the DEBUG macro. Apart from logging function_exit logs, it also
490  * processes the FD filters, if any FD filters are registered. This
491  * function_exit macro should be used for functions that returns a
492  * boolean value.
493  *
494  * \retval x Variable of type 'bool' that has to be returned
495  */
496 #define SCReturnBool(x) do { \
497  if (sc_log_global_log_level >= SC_LOG_DEBUG) { \
498  SCLogDebug("Returning: %s ... <<", x ? "true" : "false"); \
499  SCLogCheckFDFilterExit(__FUNCTION__); \
500  } \
501  return x; \
502  } while(0)
503 
504 #define SCReturnStruct(x) do { \
505  if (sc_log_global_log_level >= SC_LOG_DEBUG) { \
506  SCLogDebug("Returning: ... <<"); \
507  SCLogCheckFDFilterExit(__FUNCTION__); \
508  } \
509  return x; \
510  } while(0)
511 
512 #endif /* DEBUG */
513 
514 #define FatalError(...) \
515  do { \
516  SCLogError(__VA_ARGS__); \
517  exit(EXIT_FAILURE); \
518  } while (0)
519 
520 /** \brief Fatal error IF we're starting up, and configured to consider
521  * errors to be fatal errors */
522 #if !defined(__clang_analyzer__)
523 #define FatalErrorOnInit(...) \
524  do { \
525  SC_ATOMIC_EXTERN(unsigned int, engine_stage); \
526  int init_errors_fatal = 0; \
527  (void)SCConfGetBool("engine.init-failure-fatal", &init_errors_fatal); \
528  if (init_errors_fatal && (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT)) { \
529  SCLogError(__VA_ARGS__); \
530  exit(EXIT_FAILURE); \
531  } \
532  SCLogWarning(__VA_ARGS__); \
533  } while (0)
534 /* make it simpler for scan-build */
535 #else
536 #define FatalErrorOnInit(...) FatalError(__VA_ARGS__)
537 #endif
538 
539 #define BOOL2STR(b) (b) ? "true" : "false"
540 
542 
544 
546 
547 void SCLogDeInitLogModule(void);
548 
550 
551 int SCLogDebugEnabled(void);
552 
553 void SCLogRegisterTests(void);
554 
555 void SCLogLoadConfig(int daemon, int verbose, uint32_t userid, uint32_t groupid);
556 #endif // #ifndef SURICATA_BINDGEN_H
557 
558 void SCFatalErrorOnInitStatic(const char *);
559 
561 
562 #endif /* SURICATA_UTIL_DEBUG_H */
SCLogConfig_::op_ifaces
SCLogOPIfaceCtx * op_ifaces
Definition: util-debug.h:186
SCLogConfig_::op_filter_regex_match
pcre2_match_data * op_filter_regex_match
Definition: util-debug.h:183
SCLogAllocLogOPBuffer
SCLogOPBuffer * SCLogAllocLogOPBuffer(void)
Allocates an output buffer for an output interface. Used when we want the op_interface log_format to ...
Definition: util-debug.c:786
__SCFILENAME__
#define __SCFILENAME__
Definition: suricata-common.h:64
SCLogMessage
SCError SCLogMessage(const SCLogLevel, const char *, const unsigned int, const char *, const char *, const char *message)
Adds the global log_format to the outgoing buffer.
Definition: util-debug.c:652
SCLogOPIfaceCtx_::log_level
SCLogLevel log_level
Definition: util-debug.h:138
SCLogOPIfaceCtx_::facility
int facility
Definition: util-debug.h:135
SC_LOG_DEBUG
@ SC_LOG_DEBUG
Definition: util-debug.h:43
SC_LOG_OP_TYPE_REGULAR
@ SC_LOG_OP_TYPE_REGULAR
Definition: util-debug.h:77
SC_LOG_CONFIG
@ SC_LOG_CONFIG
Definition: util-debug.h:42
SC_LOG_NOTSET
@ SC_LOG_NOTSET
Definition: util-debug.h:35
SCLogLoadConfig
void SCLogLoadConfig(int daemon, int verbose, uint32_t userid, uint32_t groupid)
Definition: util-debug.c:1420
SCLogInitData_::global_log_format
const char * global_log_format
Definition: util-debug.h:161
SC_LOG_OP_TYPE_JSON
@ SC_LOG_OP_TYPE_JSON
Definition: util-debug.h:78
SCLogAppendOPIfaceCtx
void SCLogAppendOPIfaceCtx(SCLogOPIfaceCtx *, SCLogInitData *)
Appends an output_interface to the output_interface list sent in head.
Definition: util-debug.c:1306
SCLogErr
void void SCLogErr(int x, const char *file, const char *func, const int line, const char *module, const char *fmt,...) ATTR_FMT_PRINTF(6
sc_log_module_cleaned
int sc_log_module_cleaned
Used to indicate whether the logging module has been cleaned or not.
Definition: util-debug.c:111
SCLogOPBuffer_
Structure to be used when log_level override support would be provided by the logging module.
Definition: util-debug.h:111
SCLogOPIfaceCtx_::fp_mutex
SCMutex fp_mutex
Definition: util-debug.h:144
threads.h
SCLogOPIfaceCtx_::use_color
bool use_color
Definition: util-debug.h:123
SCLogConfig_::op_filter
char * op_filter
Definition: util-debug.h:180
SCLogAllocLogInitData
SCLogInitData * SCLogAllocLogInitData(void)
Returns a pointer to a new SCLogInitData. This is a public interface intended to be used after the lo...
Definition: util-debug.c:1250
SC_LOG_NOTICE
@ SC_LOG_NOTICE
Definition: util-debug.h:39
SCLogOPIfaceCtx_::log_format
const char * log_format
Definition: util-debug.h:141
SCLogInitData_
Structure containing init data, that would be passed to SCInitDebugModule()
Definition: util-debug.h:153
SCLogInitLogModule
void SCLogInitLogModule(SCLogInitData *)
Initializes the logging module.
Definition: util-debug.c:1390
SCLogOPType
SCLogOPType
Definition: util-debug.h:76
SCLogOPIfaceCtx_::type
SCLogOPType type
Definition: util-debug.h:124
SC_LOG_LEVEL_MAX
@ SC_LOG_LEVEL_MAX
Definition: util-debug.h:44
SCLogDeInitLogModule
void SCLogDeInitLogModule(void)
De-Initializes the logging module.
Definition: util-debug.c:1594
SCLogOPIfaceCtx_
The output interface context for the logging module.
Definition: util-debug.h:120
ATTR_FMT_PRINTF
#define ATTR_FMT_PRINTF(x, y)
Definition: suricata-common.h:427
SC_LOG_INFO
@ SC_LOG_INFO
Definition: util-debug.h:40
SCLogDebugEnabled
int SCLogDebugEnabled(void)
Returns whether debug messages are enabled to be logged or not.
Definition: util-debug.c:767
SC_LOG_ERROR
@ SC_LOG_ERROR
Definition: util-debug.h:37
util-error.h
SCFatalErrorOnInitStatic
void SCFatalErrorOnInitStatic(const char *)
Definition: util-debug.c:1614
SCLogConfig_::op_filter_regex
pcre2_code * op_filter_regex
Definition: util-debug.h:182
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: util-debug.c:101
SCLog
void SCLog(int x, const char *file, const char *func, const int line, const char *module, const char *fmt,...) ATTR_FMT_PRINTF(6
SCLogOPIface
SCLogOPIface
The various output interfaces supported.
Definition: util-debug.h:69
SCLogOPIfaceCtx
struct SCLogOPIfaceCtx_ SCLogOPIfaceCtx
The output interface context for the logging module.
SCLogConfig_::op_ifaces_cnt
uint8_t op_ifaces_cnt
Definition: util-debug.h:188
SCLogConfig_::log_level
SCLogLevel log_level
Definition: util-debug.h:177
SC_LOG_OP_IFACE_MAX
@ SC_LOG_OP_IFACE_MAX
Definition: util-debug.h:73
SCLogOPIfaceCtx_::iface
SCLogOPIface iface
Definition: util-debug.h:121
SCLogOPBuffer_::log_format
const char * log_format
Definition: util-debug.h:114
SCLogOPIfaceCtx_::file
const char * file
Definition: util-debug.h:127
SCLogOPBuffer
struct SCLogOPBuffer_ SCLogOPBuffer
Structure to be used when log_level override support would be provided by the logging module.
SCLogConfig_::startup_message
char * startup_message
Definition: util-debug.h:176
SCLogOPBuffer_::msg
char msg[SC_LOG_MAX_LOG_MSG_LEN]
Definition: util-debug.h:112
SCLogInitData_::global_log_level
SCLogLevel global_log_level
Definition: util-debug.h:158
SC_LOG_OP_IFACE_FILE
@ SC_LOG_OP_IFACE_FILE
Definition: util-debug.h:71
__attribute__
typedef __attribute__
DNP3 application header.
SCLogLevel
SCLogLevel
The various log levels NOTE: when adding new level, don't forget to update SCLogMapLogLevelToSyslogLe...
Definition: util-debug.h:34
SCLogGetLogLevel
SCLogLevel SCLogGetLogLevel(void)
Definition: util-debug.c:1070
SC_LOG_WARNING
@ SC_LOG_WARNING
Definition: util-debug.h:38
SCLogInitData_::op_filter
const char * op_filter
Definition: util-debug.h:164
suricata-common.h
SCLogConfig_::log_format
char * log_format
Definition: util-debug.h:178
SCLogOPIfaceCtx_::next
struct SCLogOPIfaceCtx_ * next
Definition: util-debug.h:146
SCError
SCError
Definition: util-error.h:26
SC_LOG_PERF
@ SC_LOG_PERF
Definition: util-debug.h:41
SCLogConfig_
Holds the config state used by the logging api.
Definition: util-debug.h:175
SCLogInitData_::op_ifaces_cnt
uint8_t op_ifaces_cnt
Definition: util-debug.h:169
SCLogOPIfaceCtx_::rotation_flag
int rotation_flag
Definition: util-debug.h:132
SC_LOG_OP_IFACE_SYSLOG
@ SC_LOG_OP_IFACE_SYSLOG
Definition: util-debug.h:72
SC_LOG_MAX_LOG_MSG_LEN
#define SC_LOG_MAX_LOG_MSG_LEN
Definition: util-debug.h:89
SCLogRegisterTests
void SCLogRegisterTests(void)
Definition: util-debug.c:1801
SCLogOPBuffer_::temp
char * temp
Definition: util-debug.h:113
SC_LOG_NONE
@ SC_LOG_NONE
Definition: util-debug.h:36
SCLogConfig
#define SCLogConfig(...)
Definition: util-debug.h:233
SCLogOPIfaceCtx_::file_d
FILE * file_d
Definition: util-debug.h:129
util-debug-filters.h
SCLogInitData_::startup_message
const char * startup_message
Definition: util-debug.h:155
SCLogInitData_::op_ifaces
SCLogOPIfaceCtx * op_ifaces
Definition: util-debug.h:167
SCLogInitData
struct SCLogInitData_ SCLogInitData
Structure containing init data, that would be passed to SCInitDebugModule()
SC_LOG_OP_IFACE_CONSOLE
@ SC_LOG_OP_IFACE_CONSOLE
Definition: util-debug.h:70
SCMutex
#define SCMutex
Definition: threads-debug.h:114
sc_log_module_initialized
int sc_log_module_initialized
Used to indicate whether the logging module has been init or not.
Definition: util-debug.c:106