• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

OISF / suricata / 23374838686

21 Mar 2026 07:29AM UTC coverage: 59.341% (-20.0%) from 79.315%
23374838686

Pull #15075

github

web-flow
Merge 90b4e834f into 6587e363a
Pull Request #15075: Stack 8001 v16.4

38 of 70 new or added lines in 10 files covered. (54.29%)

34165 existing lines in 563 files now uncovered.

119621 of 201584 relevant lines covered (59.34%)

650666.92 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

56.72
/src/util-debug.h
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 {
36
    SC_LOG_NOTSET = -1,
37
    SC_LOG_NONE = 0,
38
    SC_LOG_ERROR,
39
    SC_LOG_WARNING,
40
    SC_LOG_NOTICE,
41
    SC_LOG_INFO,
42
    SC_LOG_PERF,
43
    SC_LOG_CONFIG,
44
    SC_LOG_DEBUG,
45
    SC_LOG_LEVEL_MAX,
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"
8✔
63
#define SC_LOG_ENV_LOG_OP_IFACE  "SC_LOG_OP_IFACE"
7✔
64
#define SC_LOG_ENV_LOG_FILE      "SC_LOG_FILE"
6✔
65
#define SC_LOG_ENV_LOG_FACILITY  "SC_LOG_FACILITY"
×
66
#define SC_LOG_ENV_LOG_FORMAT    "SC_LOG_FORMAT"
8✔
67
#define SC_LOG_ENV_LOG_OP_FILTER "SC_LOG_OP_FILTER"
7✔
68

69
/**
70
 * \brief The various output interfaces supported
71
 */
72
typedef enum {
73
    SC_LOG_OP_IFACE_CONSOLE,
74
    SC_LOG_OP_IFACE_FILE,
75
    SC_LOG_OP_IFACE_SYSLOG,
76
    SC_LOG_OP_IFACE_MAX,
77
} SCLogOPIface;
78

79
typedef enum {
80
    SC_LOG_OP_TYPE_REGULAR = 0,
81
    SC_LOG_OP_TYPE_JSON,
82
} SCLogOPType;
83

84
/* The default log_format, if it is not supplied by the user */
UNCOV
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]"
7✔
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
181,050,258✔
93

94
/* The maximum length of the log format */
UNCOV
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
7✔
99

100
/* The default output interface to be used */
101
#define SC_LOG_DEF_LOG_OP_IFACE SC_LOG_OP_IFACE_CONSOLE
1✔
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_ {
115
    char msg[SC_LOG_MAX_LOG_MSG_LEN];
116
    char *temp;
117
    const char *log_format;
118
} SCLogOPBuffer;
119

120
/**
121
 * \brief The output interface context for the logging module
122
 */
123
typedef struct SCLogOPIfaceCtx_ {
124
    SCLogOPIface iface;
125

126
    bool use_color;
127
    SCLogOPType type;
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 */
135
    int rotation_flag;
136

137
    /* the facility code if the interface is SC_LOG_IFACE_SYSLOG */
138
    int facility;
139

140
    /* override for the global_log_level */
141
    SCLogLevel 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. */
147
    SCMutex fp_mutex;
148

149
    struct SCLogOPIfaceCtx_ *next;
150
} SCLogOPIfaceCtx;
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 */
161
    SCLogLevel global_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 */
170
    SCLogOPIfaceCtx *op_ifaces;
171
    /* no of op ifaces */
172
    uint8_t op_ifaces_cnt;
173
} SCLogInitData;
174

175
/**
176
 * \brief Holds the config state used by the logging api
177
 */
178
typedef struct SCLogConfig_ {
179
    char *startup_message;
180
    SCLogLevel log_level;
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 */
189
    SCLogOPIfaceCtx *op_ifaces;
190
    /* no of op ifaces */
191
    uint8_t op_ifaces_cnt;
192
} SCLogConfig;
193

194
/* The different log format specifiers supported by the API */
UNCOV
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 */
×
UNCOV
198
#define SC_LOG_FMT_TID              'i' /* Thread ID */
×
UNCOV
199
#define SC_LOG_FMT_TM               'm' /* Thread module name */
×
200
#define SC_LOG_FMT_LOG_LEVEL        'd' /* Log level */
10,650,112✔
201
#define SC_LOG_FMT_LOG_SLEVEL       'D' /* Log level */
×
202
#define SC_LOG_FMT_FILE_NAME        'f' /* File name */
10,649,935✔
203
#define SC_LOG_FMT_LINE             'l' /* Line number */
10,649,844✔
204
#define SC_LOG_FMT_FUNCTION         'n' /* Function */
10,649,971✔
205
#define SC_LOG_FMT_SUBSYSTEM        'S' /* Subsystem name */
10,650,112✔
206
#define SC_LOG_FMT_THREAD_NAME      'T' /* thread name */
×
207
#define SC_LOG_FMT_MESSAGE          'M' /* log message body */
10,650,112✔
208

209
/* The log format prefix for the format specifiers */
210
#define SC_LOG_FMT_PREFIX           '%'
74,550,057✔
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

216
extern SCLogLevel sc_log_global_log_level;
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__)
482,752✔
233
#define SCLogInfoRaw(file, func, line, ...)                                                        \
UNCOV
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__)
273,954✔
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__)
619,117✔
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__)
70,874✔
252
#define SCLogNoticeRaw(file, func, line, ...)                                                      \
UNCOV
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__)
172,684✔
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__)
9,846,301✔
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)
652,244,147✔
283

284
#define SCEnter(...)
285

286
#define SCReturn                        return
28,162,961✔
287

288
#define SCReturnInt(x)                  return x
61,854,575✔
289

290
#define SCReturnUInt(x)                 return x
6,626,368✔
291

292
#define SCReturnDbl(x)                  return x
293

294
#define SCReturnChar(x)                 return x
295

296
#define SCReturnCharPtr(x)              return x
17,747✔
297

298
#define SCReturnCT(x, type)             return x
7,650,433✔
299

300
#define SCReturnPtr(x, type)            return x
30,537,171✔
301

302
#define SCReturnBool(x)                 return x
193,990✔
303

304
#define SCReturnStruct(x)                 return x
151,911✔
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(...)                                                                            \
UNCOV
518
    do {                                                                                           \
×
UNCOV
519
        SCLogError(__VA_ARGS__);                                                                   \
×
UNCOV
520
        exit(EXIT_FAILURE);                                                                        \
×
UNCOV
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 {                                                                                           \
47✔
528
        SC_ATOMIC_EXTERN(unsigned int, engine_stage);                                              \
47✔
529
        int init_errors_fatal = 0;                                                                 \
47✔
530
        (void)SCConfGetBool("engine.init-failure-fatal", &init_errors_fatal);                      \
47✔
531
        if (init_errors_fatal && (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT)) {                 \
47✔
UNCOV
532
            SCLogError(__VA_ARGS__);                                                               \
×
UNCOV
533
            exit(EXIT_FAILURE);                                                                    \
×
UNCOV
534
        }                                                                                          \
×
535
        SCLogWarning(__VA_ARGS__);                                                                 \
47✔
536
    } while (0)
47✔
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

544
SCLogInitData *SCLogAllocLogInitData(void);
545

546
void SCLogAppendOPIfaceCtx(SCLogOPIfaceCtx *, SCLogInitData *);
547

548
void SCLogInitLogModule(SCLogInitData *);
549

550
void SCLogDeInitLogModule(void);
551

552
SCLogOPBuffer *SCLogAllocLogOPBuffer(void);
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

563
SCLogLevel SCLogGetLogLevel(void);
564

565
#endif /* SURICATA_UTIL_DEBUG_H */
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc