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

OISF / suricata / 22550902417

01 Mar 2026 07:32PM UTC coverage: 68.401% (-5.3%) from 73.687%
22550902417

Pull #14922

github

web-flow
github-actions: bump actions/upload-artifact from 6.0.0 to 7.0.0

Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 6.0.0 to 7.0.0.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v6...v7)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: 7.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #14922: github-actions: bump actions/upload-artifact from 6.0.0 to 7.0.0

218243 of 319063 relevant lines covered (68.4%)

3284926.58 hits per line

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

11.11
/rust/src/debug.rs
1
/* Copyright (C) 2017-2025 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
//! Logging and debug utilities, like util-debug.c.
19

20
use std::path::Path;
21

22
use suricata_sys::sys::SCLogLevel;
23
#[cfg(not(test))]
24
use suricata_sys::sys::SCError;
25

26
pub static mut LEVEL: SCLogLevel = SCLogLevel::SC_LOG_NOTSET;
27

28
/// Set the Rust context's idea of the log level.
29
///
30
/// This will be called during Suricata initialization with the
31
/// runtime log level.
32
#[no_mangle]
33
pub unsafe extern "C" fn SCSetRustLogLevel(level: SCLogLevel) {
58✔
34
    LEVEL = level;
58✔
35
}
58✔
36

37
fn basename(filename: &str) -> &str {
×
38
    let path = Path::new(filename);
×
39
    if let Some(os_str) = path.file_name() {
×
40
        if let Some(basename) = os_str.to_str() {
×
41
            return basename;
×
42
        }
×
43
    }
×
44
    return filename;
×
45
}
×
46

47
pub fn sclog(level: SCLogLevel, file: &str, line: u32, function: &str, message: &str) {
×
48
    let filename = basename(file);
×
49
    let noext = &filename[0..filename.len() - 3];
×
50
    sc_log_message(level, filename, line, function, noext, message);
×
51
}
×
52

53
/// SCLogMessage wrapper. If the Suricata C context is not registered
54
/// a more basic log format will be used (for example, when running
55
/// Rust unit tests).
56
#[cfg(not(test))]
57
pub fn sc_log_message(
×
58
    level: SCLogLevel, filename: &str, line: std::os::raw::c_uint, function: &str, module: &str,
×
59
    message: &str,
×
60
) -> SCError {
×
61
    suricata_ffi::debug::log_message(level, filename, line, function, module, message)
×
62
}
×
63

64
#[cfg(test)]
65
pub fn sc_log_message(
66
    level: SCLogLevel, filename: &str, line: std::os::raw::c_uint, _function: &str, _module: &str,
67
    message: &str,
68
) -> i32 {
69
    // Fall back if the Suricata C context is not registered which is
70
    // the case when Rust unit tests are running.
71
    //
72
    // We don't log the time right now as I don't think it can be done
73
    // with Rust 1.7.0 without using an external crate. With Rust
74
    // 1.8.0 and newer we can unix UNIX_EPOCH.elapsed() to get the
75
    // unix time.
76
    println!("{}:{} <{:?}> -- {}", filename, line, level, message);
77
    return 0;
78
}
79

80
// This macro returns the function name.
81
//
82
// This macro has been borrowed from https://github.com/popzxc/stdext-rs, which
83
// is released under the MIT license as there is currently no macro in Rust
84
// to provide the function name.
85
#[macro_export(local_inner_macros)]
86
macro_rules! function {
87
    () => {{
88
        // Okay, this is ugly, I get it. However, this is the best we can get on a stable rust.
89
        fn __f() {}
×
90
        fn type_name_of<T>(_: T) -> &'static str {
×
91
            std::any::type_name::<T>()
×
92
        }
×
93
        let name = type_name_of(__f);
94
        &name[..name.len() - 5]
95
    }};
96
}
97

98
#[macro_export]
99
macro_rules!do_log {
100
    ($level:expr, $($arg:tt)*) => {
101
        #[allow(unused_unsafe)]
102
        if unsafe { $crate::debug::LEVEL as i32 } >= $level as i32 {
103
            $crate::debug::sclog($level, file!(), line!(), $crate::function!(),
104
                  &(format!($($arg)*)));
105
        }
106
    }
107
}
108

109
#[macro_export]
110
macro_rules!SCLogError {
111
    ($($arg:tt)*) => {
112
        $crate::do_log!(suricata_sys::sys::SCLogLevel::SC_LOG_ERROR, $($arg)*);
113
    };
114
}
115

116
#[macro_export]
117
macro_rules!SCLogWarning {
118
    ($($arg:tt)*) => {
119
        $crate::do_log!(suricata_sys::sys::SCLogLevel::SC_LOG_WARNING, $($arg)*);
120
    };
121
}
122

123
#[macro_export]
124
macro_rules!SCLogNotice {
125
    ($($arg:tt)*) => {
126
        $crate::do_log!(suricata_sys::sys::SCLogLevel::SC_LOG_NOTICE, $($arg)*);
127
    }
128
}
129

130
#[macro_export]
131
macro_rules!SCLogInfo {
132
    ($($arg:tt)*) => {
133
        $crate::do_log!(suricata_sys::sys::SCLogLevel::SC_LOG_INFO, $($arg)*);
134
    }
135
}
136

137
#[macro_export]
138
macro_rules!SCLogPerf {
139
    ($($arg:tt)*) => {
140
        $crate::do_log!(suricata_sys::sys::SCLogLevel::SC_LOG_PERF, $($arg)*);
141
    }
142
}
143

144
#[macro_export]
145
macro_rules!SCLogConfig {
146
    ($($arg:tt)*) => {
147
        $crate::do_log!(suricata_sys::sys::SCLogLevel::SC_LOG_CONFIG, $($arg)*);
148
    }
149
}
150

151
// Debug mode: call C SCLogDebug
152
#[cfg(feature = "debug")]
153
#[macro_export]
154
macro_rules!SCLogDebug {
155
    ($($arg:tt)*) => {
156
        do_log!(suricata_sys::sys::SCLogLevel::SC_LOG_DEBUG, $($arg)*);
157
    }
158
}
159

160
// SCLogDebug variation to use when not compiled with debug support.
161
//
162
// This macro will only use the parameters passed to prevent warnings
163
// about unused variables, but is otherwise the equivalent to a no-op.
164
#[cfg(not(feature = "debug"))]
165
#[macro_export]
166
macro_rules! SCLogDebug {
167
    ($($arg:tt)*) => {};
168
}
169

170
#[macro_export]
171
macro_rules!SCFatalErrorOnInit {
172
    ($($arg:tt)*) => {
173
        suricata_ffi::debug::fatalerror(&format!($($arg)*));
174
    }
175
}
176

177
#[cfg(not(feature = "debug-validate"))]
178
#[macro_export]
179
macro_rules! debug_validate_bug_on (
180
  ($item:expr) => {};
181
);
182

183
#[cfg(feature = "debug-validate")]
184
#[macro_export]
185
macro_rules! debug_validate_bug_on (
186
  ($item:expr) => {
187
    if $item {
188
        panic!("Condition check failed");
189
    }
190
  };
191
);
192

193
#[cfg(not(feature = "debug-validate"))]
194
#[macro_export]
195
macro_rules! debug_validate_fail (
196
  ($msg:expr) => {};
197
);
198

199
#[cfg(feature = "debug-validate")]
200
#[macro_export]
201
macro_rules! debug_validate_fail (
202
  ($msg:expr) => {
203
    // Wrap in a conditional to prevent unreachable code warning in caller.
204
    if true {
205
      panic!($msg);
206
    }
207
  };
208
);
209

210
#[macro_export]
211
macro_rules! unwrap_or_return (
212
    ($e:expr, $r:expr) => {
213
        match $e {
214
            Ok(x) => x,
215
            Err(_) => return $r,
216
        }
217
    };
218
);
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