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