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