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