1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
use std::os::raw::{c_char, c_int};
use super::{rcutils_allocator_t, rcutils_ret_t, rcutils_time_point_value_t};
use crate::va_list;
extern "C" {
pub static mut g_rcutils_logging_initialized: bool;
pub fn rcutils_logging_initialize_with_allocator(
allocator: rcutils_allocator_t,
) -> rcutils_ret_t;
pub fn rcutils_logging_initialize() -> rcutils_ret_t;
pub fn rcutils_logging_shutdown() -> rcutils_ret_t;
}
#[repr(C)]
#[derive(Debug)]
pub struct rcutils_log_location_t {
pub function_name: *const c_char,
pub file_name: *const c_char,
pub line_number: usize,
}
#[repr(i32)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum RcutilsLogSeverity {
Unset = 0,
Debug = 10,
Info = 20,
Warn = 30,
Error = 40,
Fatal = 50,
}
impl RcutilsLogSeverity {
pub fn try_from_int(from: i32) -> Option<Self> {
Some(match from {
v if v == Self::Unset as i32 => Self::Unset,
v if v == Self::Debug as i32 => Self::Debug,
v if v == Self::Info as i32 => Self::Info,
v if v == Self::Warn as i32 => Self::Warn,
v if v == Self::Error as i32 => Self::Error,
v if v == Self::Fatal as i32 => Self::Fatal,
_ => return None,
})
}
}
impl From<RcutilsLogSeverity> for i32 {
fn from(from: RcutilsLogSeverity) -> Self {
from as Self
}
}
pub type rcutils_logging_output_handler_t = Option<
unsafe extern "C" fn(
arg1: *const rcutils_log_location_t,
arg2: c_int,
arg3: *const c_char,
arg4: rcutils_time_point_value_t,
arg5: *const c_char,
arg6: *mut va_list,
),
>;
extern "C" {
pub fn rcutils_logging_get_default_logger_level() -> c_int;
pub fn rcutils_logging_set_default_logger_level(level: c_int);
pub fn rcutils_logging_get_logger_level(name: *const c_char) -> c_int;
pub fn rcutils_logging_set_logger_level(name: *const c_char, level: c_int) -> rcutils_ret_t;
pub fn rcutils_logging_logger_is_enabled_for(name: *const c_char, severity: c_int) -> bool;
pub fn rcutils_logging_get_logger_effective_level(name: *const c_char) -> c_int;
pub fn rcutils_log(
location: *const rcutils_log_location_t,
severity: c_int,
name: *const c_char,
format: *const c_char,
);
pub fn rcutils_logging_console_output_handler(
location: *const rcutils_log_location_t,
severity: c_int,
name: *const c_char,
timestamp: rcutils_time_point_value_t,
format: *const c_char,
args: *mut va_list,
);
}