hilog_sys/hilog_ffi.rs
1// automatically generated by rust-bindgen 0.71.1
2
3#![allow(non_upper_case_globals)]
4#![allow(non_camel_case_types)]
5#![allow(non_snake_case)]
6
7impl LogType {
8 /// Third-party application logs
9 pub const LOG_APP: LogType = LogType(0);
10}
11#[repr(transparent)]
12/// Enumerates log types.
13///
14/// Currently, <b>LOG_APP</b> is available.
15///
16///
17///
18/// Available since API-level: 8
19#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
20pub struct LogType(pub ::core::ffi::c_uint);
21impl LogLevel {
22 /// Debug level to be used by [`OH_LOG_DEBUG`]
23 pub const LOG_DEBUG: LogLevel = LogLevel(3);
24 /// Informational level to be used by [`OH_LOG_INFO`]
25 pub const LOG_INFO: LogLevel = LogLevel(4);
26 /// Warning level to be used by [`OH_LOG_WARN`]
27 pub const LOG_WARN: LogLevel = LogLevel(5);
28 /// Error level to be used by [`OH_LOG_ERROR`]
29 pub const LOG_ERROR: LogLevel = LogLevel(6);
30 /// Fatal level to be used by [`OH_LOG_FATAL`]
31 pub const LOG_FATAL: LogLevel = LogLevel(7);
32}
33#[repr(transparent)]
34/// Enumerates log levels.
35///
36/// You are advised to select log levels based on their respective usage scenarios:
37///
38/// <ul><li><b>DEBUG</b>: used for debugging and disabled from commercial releases</li>
39///
40/// <li><b>INFO</b>: used for logging important system running status and steps in key processes</li>
41///
42/// <li><b>WARN</b>: used for logging unexpected exceptions that have little impact on user experience and can
43/// automatically recover. Logs at this level are generally output when such exceptions are detected and
44/// captured.</li>
45///
46/// <li><b>ERROR</b>: used for logging malfunction that affects user experience and cannot automatically
47/// recover</li>
48///
49/// <li><b>FATAL</b>: used for logging major exceptions that have severely affected user experience and should
50/// not occur.</li></ul>
51///
52///
53///
54/// Available since API-level: 8
55#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
56pub struct LogLevel(pub ::core::ffi::c_uint);
57#[cfg(feature = "api-21")]
58#[cfg_attr(docsrs, doc(cfg(feature = "api-21")))]
59impl PreferStrategy {
60 /// Used to unset SetLogLevel, then none is set
61 pub const UNSET_LOGLEVEL: PreferStrategy = PreferStrategy(0);
62 /// The actual lowest log level is determined by
63 /// the maximum level between the new level and the system-controlled level.
64 /// This is equivalent to calling OH_LOG_SetMinLogLevel.
65 pub const PREFER_CLOSE_LOG: PreferStrategy = PreferStrategy(1);
66 /// The actual lowest log level is determined by
67 /// the minimum level between the new level and the system-controlled level.
68 pub const PREFER_OPEN_LOG: PreferStrategy = PreferStrategy(2);
69}
70#[repr(transparent)]
71/// Enumerates preference strategy to be used in [`OH_LOG_SetLogLevel`].
72///
73/// You are advised to select preference strategy based on their respective usage scenarios.
74///
75///
76/// Available since API-level: 21
77#[cfg(feature = "api-21")]
78#[cfg_attr(docsrs, doc(cfg(feature = "api-21")))]
79#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
80pub struct PreferStrategy(pub ::core::ffi::c_uint);
81/// Defines the function pointer type for the user-defined log processing function.
82///
83/// # Arguments
84///
85/// * `type` - Indicates the log type. The type for third-party applications is defined by [`LOG_APP`].
86///
87/// * `level` - Indicates the log level, which can be <b>LOG_DEBUG</b>, <b>LOG_INFO</b>, <b>LOG_WARN</b>,
88/// <b>LOG_ERROR</b>, and <b>LOG_FATAL</b>.
89///
90/// * `domain` - Indicates the service domain of logs. Its value is a hexadecimal integer ranging from 0x0 to 0xFFFF.
91///
92/// * `tag` - Indicates the log tag, which is a string used to identify the class, file, or service behavior.
93///
94/// * `msg` - Indicates the log message itself, which is a formatted log string.
95///
96/// Available since API-level: 11
97#[cfg(feature = "api-11")]
98#[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
99pub type LogCallback = ::core::option::Option<
100 unsafe extern "C" fn(
101 type_: LogType,
102 level: LogLevel,
103 domain: ::core::ffi::c_uint,
104 tag: *const ::core::ffi::c_char,
105 msg: *const ::core::ffi::c_char,
106 ),
107>;
108extern "C" {
109 /// Outputs logs.
110 ///
111 /// You can use this function to output logs based on the specified log type, log level, service domain, log tag,
112 /// and variable parameters determined by the format specifier and privacy identifier in the printf format.
113 ///
114 /// # Arguments
115 ///
116 /// * `type` - Indicates the log type. The type for third-party applications is defined by [`LOG_APP`].
117 ///
118 /// * `level` - Indicates the log level, which can be <b>LOG_DEBUG</b>, <b>LOG_INFO</b>, <b>LOG_WARN</b>,
119 /// <b>LOG_ERROR</b>, and <b>LOG_FATAL</b>.
120 ///
121 /// * `domain` - Indicates the service domain of logs. Its value is a hexadecimal integer ranging from 0x0 to 0xFFFF.
122 ///
123 /// * `tag` - Indicates the log tag, which is a string used to identify the class, file, or service behavior.
124 ///
125 /// * `fmt` - Indicates the format string, which is an enhancement of a printf format string and supports the privacy
126 /// identifier. Specifically, {public} or {private} is added between the % character and the format specifier
127 /// in each parameter.
128 ///
129 ///
130 /// * `...` - Indicates a list of parameters. The number and type of parameters must map onto the format specifiers
131 /// in the format string.
132 ///
133 /// # Returns
134 ///
135 /// * Returns <b>0</b> or a larger value if the operation is successful; returns a value smaller
136 /// than <b>0</b> otherwise.
137 ///
138 /// Available since API-level: 8
139 pub fn OH_LOG_Print(
140 type_: LogType,
141 level: LogLevel,
142 domain: ::core::ffi::c_uint,
143 tag: *const ::core::ffi::c_char,
144 fmt: *const ::core::ffi::c_char,
145 ...
146 ) -> ::core::ffi::c_int;
147 /// Outputs logs.
148 ///
149 /// You can use this function to output logs based on the specified log type, log level, service domain, log tag,
150 /// and message text.
151 ///
152 /// # Arguments
153 ///
154 /// * `type` - Indicates the log type. The type for third-party applications is defined by [`LOG_APP`].
155 ///
156 /// * `level` - Indicates the log level, which can be <b>LOG_DEBUG</b>, <b>LOG_INFO</b>, <b>LOG_WARN</b>,
157 /// <b>LOG_ERROR</b>, and <b>LOG_FATAL</b>.
158 ///
159 /// * `domain` - Indicates the service domain of logs. Its value is a hexadecimal integer ranging from 0x0 to 0xFFFF.
160 ///
161 /// * `tag` - Indicates the log tag, which is a string used to identify the class, file, or service behavior.
162 ///
163 /// * `message` - Indicates the log string.
164 ///
165 /// # Returns
166 ///
167 /// * Returns <b>0</b> or a larger value if the operation is successful; returns a value smaller
168 /// than <b>0</b> otherwise.
169 ///
170 /// Available since API-level: 18
171 #[cfg(feature = "api-18")]
172 #[cfg_attr(docsrs, doc(cfg(feature = "api-18")))]
173 pub fn OH_LOG_PrintMsg(
174 type_: LogType,
175 level: LogLevel,
176 domain: ::core::ffi::c_uint,
177 tag: *const ::core::ffi::c_char,
178 message: *const ::core::ffi::c_char,
179 ) -> ::core::ffi::c_int;
180 /// Outputs logs.
181 ///
182 /// You can use this function to output logs based on the specified log type, log level, service domain, log tag,
183 /// message text and message length.
184 ///
185 /// # Arguments
186 ///
187 /// * `type` - Indicates the log type. The type for third-party applications is defined by [`LOG_APP`].
188 ///
189 /// * `level` - Indicates the log level, which can be <b>LOG_DEBUG</b>, <b>LOG_INFO</b>, <b>LOG_WARN</b>,
190 /// <b>LOG_ERROR</b>, and <b>LOG_FATAL</b>.
191 ///
192 /// * `domain` - Indicates the service domain of logs. Its value is a hexadecimal integer ranging from 0x0 to 0xFFFF.
193 ///
194 /// * `tag` - Indicates the log tag, which is a string used to identify the class, file, or service behavior.
195 ///
196 /// * `tagLen` - Indicates the length of tag.
197 ///
198 /// * `message` - Indicates the log string.
199 ///
200 /// * `messageLen` - Indicates the length of message.
201 ///
202 /// # Returns
203 ///
204 /// * Returns <b>0</b> or a larger value if the operation is successful; returns a value smaller
205 /// than <b>0</b> otherwise.
206 ///
207 /// Available since API-level: 18
208 #[cfg(feature = "api-18")]
209 #[cfg_attr(docsrs, doc(cfg(feature = "api-18")))]
210 pub fn OH_LOG_PrintMsgByLen(
211 type_: LogType,
212 level: LogLevel,
213 domain: ::core::ffi::c_uint,
214 tag: *const ::core::ffi::c_char,
215 tagLen: usize,
216 message: *const ::core::ffi::c_char,
217 messageLen: usize,
218 ) -> ::core::ffi::c_int;
219 /// Checks whether logs of the specified service domain, log tag, and log level can be output.
220 ///
221 /// # Arguments
222 ///
223 /// * `domain` - Indicates the service domain of logs.
224 ///
225 /// * `tag` - Indicates the log tag.
226 ///
227 /// * `level` - Indicates the log level.
228 ///
229 /// # Returns
230 ///
231 /// * Returns <b>true</b> if the specified logs can be output; returns <b>false</b> otherwise.
232 ///
233 /// Available since API-level: 8
234 pub fn OH_LOG_IsLoggable(
235 domain: ::core::ffi::c_uint,
236 tag: *const ::core::ffi::c_char,
237 level: LogLevel,
238 ) -> bool;
239 /// Set the user-defined log processing function.
240 ///
241 /// After calling this function, the callback function implemented by the user can receive all hilogs of the
242 /// current process.
243 /// Note that it will not change the default behavior of hilog logs of the current process, no matter whether this
244 /// interface is called or not.
245 ///
246 ///
247 /// # Arguments
248 ///
249 /// * `callback` - Indicates the callback function implemented by the user. If you do not need to process hilog logs,
250 /// you can transfer a null pointer.
251 ///
252 /// Available since API-level: 11
253 #[cfg(feature = "api-11")]
254 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
255 pub fn OH_LOG_SetCallback(callback: LogCallback);
256 /// Sets the lowest log level of the current application process.
257 ///
258 /// # Arguments
259 ///
260 /// * `level` - log level
261 ///
262 /// Available since API-level: 15
263 #[cfg(feature = "api-15")]
264 #[cfg_attr(docsrs, doc(cfg(feature = "api-15")))]
265 pub fn OH_LOG_SetMinLogLevel(level: LogLevel);
266 /// Sets the lowest log level of the current application process. Different preference strategy can be set.
267 ///
268 /// # Arguments
269 ///
270 /// * `level` - log level.
271 ///
272 /// * `prefer` - preference strategy. See [`PreferStrategy`].
273 ///
274 /// Available since API-level: 21
275 #[cfg(feature = "api-21")]
276 #[cfg_attr(docsrs, doc(cfg(feature = "api-21")))]
277 pub fn OH_LOG_SetLogLevel(level: LogLevel, prefer: PreferStrategy);
278}