sdl3_sys/generated/log.rs
1//! Simple log messages with priorities and categories. A message's
2//! [`SDL_LogPriority`] signifies how important the message is. A message's
3//! [`SDL_LogCategory`] signifies from what domain it belongs to. Every category
4//! has a minimum priority specified: when a message belongs to that category,
5//! it will only be sent out if it has that minimum priority or higher.
6//!
7//! SDL's own logs are sent below the default priority threshold, so they are
8//! quiet by default.
9//!
10//! You can change the log verbosity programmatically using
11//! [`SDL_SetLogPriority()`] or with SDL_SetHint([`SDL_HINT_LOGGING`], ...), or with
12//! the "SDL_LOGGING" environment variable. This variable is a comma separated
13//! set of category=level tokens that define the default logging levels for SDL
14//! applications.
15//!
16//! The category can be a numeric category, one of "app", "error", "assert",
17//! "system", "audio", "video", "render", "input", "test", or `*` for any
18//! unspecified category.
19//!
20//! The level can be a numeric level, one of "trace", "verbose", "debug",
21//! "info", "warn", "error", "critical", or "quiet" to disable that category.
22//!
23//! You can omit the category if you want to set the logging level for all
24//! categories.
25//!
26//! If this hint isn't set, the default log levels are equivalent to:
27//!
28//! `app=info,assert=warn,test=verbose,*=error`
29//!
30//! Here's where the messages go on different platforms:
31//!
32//! - Windows: debug output stream
33//! - Android: log output
34//! - Others: standard error output (stderr)
35//!
36//! You don't need to have a newline (`\n`) on the end of messages, the
37//! functions will do that for you. For consistent behavior cross-platform, you
38//! shouldn't have any newlines in messages, such as to log multiple lines in
39//! one call; unusual platform-specific behavior can be observed in such usage.
40//! Do one log call per line instead, with no newlines in messages.
41//!
42//! Each log call is atomic, so you won't see log messages cut off one another
43//! when logging from multiple threads.
44
45use super::stdinc::*;
46
47/// The predefined log categories
48///
49/// By default the application and gpu categories are enabled at the INFO
50/// level, the assert category is enabled at the WARN level, test is enabled at
51/// the VERBOSE level and all other categories are enabled at the ERROR level.
52///
53/// ## Availability
54/// This enum is available since SDL 3.2.0.
55///
56/// ## Known values (`sdl3-sys`)
57/// | Associated constant | Global constant | Description |
58/// | ------------------- | --------------- | ----------- |
59/// | [`APPLICATION`](SDL_LogCategory::APPLICATION) | [`SDL_LOG_CATEGORY_APPLICATION`] | |
60/// | [`ERROR`](SDL_LogCategory::ERROR) | [`SDL_LOG_CATEGORY_ERROR`] | |
61/// | [`ASSERT`](SDL_LogCategory::ASSERT) | [`SDL_LOG_CATEGORY_ASSERT`] | |
62/// | [`SYSTEM`](SDL_LogCategory::SYSTEM) | [`SDL_LOG_CATEGORY_SYSTEM`] | |
63/// | [`AUDIO`](SDL_LogCategory::AUDIO) | [`SDL_LOG_CATEGORY_AUDIO`] | |
64/// | [`VIDEO`](SDL_LogCategory::VIDEO) | [`SDL_LOG_CATEGORY_VIDEO`] | |
65/// | [`RENDER`](SDL_LogCategory::RENDER) | [`SDL_LOG_CATEGORY_RENDER`] | |
66/// | [`INPUT`](SDL_LogCategory::INPUT) | [`SDL_LOG_CATEGORY_INPUT`] | |
67/// | [`TEST`](SDL_LogCategory::TEST) | [`SDL_LOG_CATEGORY_TEST`] | |
68/// | [`GPU`](SDL_LogCategory::GPU) | [`SDL_LOG_CATEGORY_GPU`] | |
69/// | [`RESERVED2`](SDL_LogCategory::RESERVED2) | [`SDL_LOG_CATEGORY_RESERVED2`] | |
70/// | [`RESERVED3`](SDL_LogCategory::RESERVED3) | [`SDL_LOG_CATEGORY_RESERVED3`] | |
71/// | [`RESERVED4`](SDL_LogCategory::RESERVED4) | [`SDL_LOG_CATEGORY_RESERVED4`] | |
72/// | [`RESERVED5`](SDL_LogCategory::RESERVED5) | [`SDL_LOG_CATEGORY_RESERVED5`] | |
73/// | [`RESERVED6`](SDL_LogCategory::RESERVED6) | [`SDL_LOG_CATEGORY_RESERVED6`] | |
74/// | [`RESERVED7`](SDL_LogCategory::RESERVED7) | [`SDL_LOG_CATEGORY_RESERVED7`] | |
75/// | [`RESERVED8`](SDL_LogCategory::RESERVED8) | [`SDL_LOG_CATEGORY_RESERVED8`] | |
76/// | [`RESERVED9`](SDL_LogCategory::RESERVED9) | [`SDL_LOG_CATEGORY_RESERVED9`] | |
77/// | [`RESERVED10`](SDL_LogCategory::RESERVED10) | [`SDL_LOG_CATEGORY_RESERVED10`] | |
78/// | [`CUSTOM`](SDL_LogCategory::CUSTOM) | [`SDL_LOG_CATEGORY_CUSTOM`] | |
79#[repr(transparent)]
80#[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
81pub struct SDL_LogCategory(pub ::core::ffi::c_int);
82
83impl ::core::cmp::PartialEq<::core::ffi::c_int> for SDL_LogCategory {
84 #[inline(always)]
85 fn eq(&self, other: &::core::ffi::c_int) -> bool {
86 &self.0 == other
87 }
88}
89
90impl ::core::cmp::PartialEq<SDL_LogCategory> for ::core::ffi::c_int {
91 #[inline(always)]
92 fn eq(&self, other: &SDL_LogCategory) -> bool {
93 self == &other.0
94 }
95}
96
97impl From<SDL_LogCategory> for ::core::ffi::c_int {
98 #[inline(always)]
99 fn from(value: SDL_LogCategory) -> Self {
100 value.0
101 }
102}
103
104#[cfg(feature = "debug-impls")]
105impl ::core::fmt::Debug for SDL_LogCategory {
106 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
107 #[allow(unreachable_patterns)]
108 f.write_str(match *self {
109 Self::APPLICATION => "SDL_LOG_CATEGORY_APPLICATION",
110 Self::ERROR => "SDL_LOG_CATEGORY_ERROR",
111 Self::ASSERT => "SDL_LOG_CATEGORY_ASSERT",
112 Self::SYSTEM => "SDL_LOG_CATEGORY_SYSTEM",
113 Self::AUDIO => "SDL_LOG_CATEGORY_AUDIO",
114 Self::VIDEO => "SDL_LOG_CATEGORY_VIDEO",
115 Self::RENDER => "SDL_LOG_CATEGORY_RENDER",
116 Self::INPUT => "SDL_LOG_CATEGORY_INPUT",
117 Self::TEST => "SDL_LOG_CATEGORY_TEST",
118 Self::GPU => "SDL_LOG_CATEGORY_GPU",
119 Self::RESERVED2 => "SDL_LOG_CATEGORY_RESERVED2",
120 Self::RESERVED3 => "SDL_LOG_CATEGORY_RESERVED3",
121 Self::RESERVED4 => "SDL_LOG_CATEGORY_RESERVED4",
122 Self::RESERVED5 => "SDL_LOG_CATEGORY_RESERVED5",
123 Self::RESERVED6 => "SDL_LOG_CATEGORY_RESERVED6",
124 Self::RESERVED7 => "SDL_LOG_CATEGORY_RESERVED7",
125 Self::RESERVED8 => "SDL_LOG_CATEGORY_RESERVED8",
126 Self::RESERVED9 => "SDL_LOG_CATEGORY_RESERVED9",
127 Self::RESERVED10 => "SDL_LOG_CATEGORY_RESERVED10",
128 Self::CUSTOM => "SDL_LOG_CATEGORY_CUSTOM",
129
130 _ => return write!(f, "SDL_LogCategory({})", self.0),
131 })
132 }
133}
134
135impl SDL_LogCategory {
136 pub const APPLICATION: Self = Self((0 as ::core::ffi::c_int));
137 pub const ERROR: Self = Self((1 as ::core::ffi::c_int));
138 pub const ASSERT: Self = Self((2 as ::core::ffi::c_int));
139 pub const SYSTEM: Self = Self((3 as ::core::ffi::c_int));
140 pub const AUDIO: Self = Self((4 as ::core::ffi::c_int));
141 pub const VIDEO: Self = Self((5 as ::core::ffi::c_int));
142 pub const RENDER: Self = Self((6 as ::core::ffi::c_int));
143 pub const INPUT: Self = Self((7 as ::core::ffi::c_int));
144 pub const TEST: Self = Self((8 as ::core::ffi::c_int));
145 pub const GPU: Self = Self((9 as ::core::ffi::c_int));
146 pub const RESERVED2: Self = Self((10 as ::core::ffi::c_int));
147 pub const RESERVED3: Self = Self((11 as ::core::ffi::c_int));
148 pub const RESERVED4: Self = Self((12 as ::core::ffi::c_int));
149 pub const RESERVED5: Self = Self((13 as ::core::ffi::c_int));
150 pub const RESERVED6: Self = Self((14 as ::core::ffi::c_int));
151 pub const RESERVED7: Self = Self((15 as ::core::ffi::c_int));
152 pub const RESERVED8: Self = Self((16 as ::core::ffi::c_int));
153 pub const RESERVED9: Self = Self((17 as ::core::ffi::c_int));
154 pub const RESERVED10: Self = Self((18 as ::core::ffi::c_int));
155 pub const CUSTOM: Self = Self((19 as ::core::ffi::c_int));
156}
157
158pub const SDL_LOG_CATEGORY_APPLICATION: SDL_LogCategory = SDL_LogCategory::APPLICATION;
159pub const SDL_LOG_CATEGORY_ERROR: SDL_LogCategory = SDL_LogCategory::ERROR;
160pub const SDL_LOG_CATEGORY_ASSERT: SDL_LogCategory = SDL_LogCategory::ASSERT;
161pub const SDL_LOG_CATEGORY_SYSTEM: SDL_LogCategory = SDL_LogCategory::SYSTEM;
162pub const SDL_LOG_CATEGORY_AUDIO: SDL_LogCategory = SDL_LogCategory::AUDIO;
163pub const SDL_LOG_CATEGORY_VIDEO: SDL_LogCategory = SDL_LogCategory::VIDEO;
164pub const SDL_LOG_CATEGORY_RENDER: SDL_LogCategory = SDL_LogCategory::RENDER;
165pub const SDL_LOG_CATEGORY_INPUT: SDL_LogCategory = SDL_LogCategory::INPUT;
166pub const SDL_LOG_CATEGORY_TEST: SDL_LogCategory = SDL_LogCategory::TEST;
167pub const SDL_LOG_CATEGORY_GPU: SDL_LogCategory = SDL_LogCategory::GPU;
168pub const SDL_LOG_CATEGORY_RESERVED2: SDL_LogCategory = SDL_LogCategory::RESERVED2;
169pub const SDL_LOG_CATEGORY_RESERVED3: SDL_LogCategory = SDL_LogCategory::RESERVED3;
170pub const SDL_LOG_CATEGORY_RESERVED4: SDL_LogCategory = SDL_LogCategory::RESERVED4;
171pub const SDL_LOG_CATEGORY_RESERVED5: SDL_LogCategory = SDL_LogCategory::RESERVED5;
172pub const SDL_LOG_CATEGORY_RESERVED6: SDL_LogCategory = SDL_LogCategory::RESERVED6;
173pub const SDL_LOG_CATEGORY_RESERVED7: SDL_LogCategory = SDL_LogCategory::RESERVED7;
174pub const SDL_LOG_CATEGORY_RESERVED8: SDL_LogCategory = SDL_LogCategory::RESERVED8;
175pub const SDL_LOG_CATEGORY_RESERVED9: SDL_LogCategory = SDL_LogCategory::RESERVED9;
176pub const SDL_LOG_CATEGORY_RESERVED10: SDL_LogCategory = SDL_LogCategory::RESERVED10;
177pub const SDL_LOG_CATEGORY_CUSTOM: SDL_LogCategory = SDL_LogCategory::CUSTOM;
178
179#[cfg(feature = "metadata")]
180impl sdl3_sys::metadata::GroupMetadata for SDL_LogCategory {
181 const GROUP_METADATA: &'static sdl3_sys::metadata::Group =
182 &crate::metadata::log::METADATA_SDL_LogCategory;
183}
184
185/// The predefined log priorities
186///
187/// ## Availability
188/// This enum is available since SDL 3.2.0.
189///
190/// ## Known values (`sdl3-sys`)
191/// | Associated constant | Global constant | Description |
192/// | ------------------- | --------------- | ----------- |
193/// | [`INVALID`](SDL_LogPriority::INVALID) | [`SDL_LOG_PRIORITY_INVALID`] | |
194/// | [`TRACE`](SDL_LogPriority::TRACE) | [`SDL_LOG_PRIORITY_TRACE`] | |
195/// | [`VERBOSE`](SDL_LogPriority::VERBOSE) | [`SDL_LOG_PRIORITY_VERBOSE`] | |
196/// | [`DEBUG`](SDL_LogPriority::DEBUG) | [`SDL_LOG_PRIORITY_DEBUG`] | |
197/// | [`INFO`](SDL_LogPriority::INFO) | [`SDL_LOG_PRIORITY_INFO`] | |
198/// | [`WARN`](SDL_LogPriority::WARN) | [`SDL_LOG_PRIORITY_WARN`] | |
199/// | [`ERROR`](SDL_LogPriority::ERROR) | [`SDL_LOG_PRIORITY_ERROR`] | |
200/// | [`CRITICAL`](SDL_LogPriority::CRITICAL) | [`SDL_LOG_PRIORITY_CRITICAL`] | |
201/// | [`COUNT`](SDL_LogPriority::COUNT) | [`SDL_LOG_PRIORITY_COUNT`] | |
202#[repr(transparent)]
203#[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
204pub struct SDL_LogPriority(pub ::core::ffi::c_int);
205
206impl ::core::cmp::PartialEq<::core::ffi::c_int> for SDL_LogPriority {
207 #[inline(always)]
208 fn eq(&self, other: &::core::ffi::c_int) -> bool {
209 &self.0 == other
210 }
211}
212
213impl ::core::cmp::PartialEq<SDL_LogPriority> for ::core::ffi::c_int {
214 #[inline(always)]
215 fn eq(&self, other: &SDL_LogPriority) -> bool {
216 self == &other.0
217 }
218}
219
220impl From<SDL_LogPriority> for ::core::ffi::c_int {
221 #[inline(always)]
222 fn from(value: SDL_LogPriority) -> Self {
223 value.0
224 }
225}
226
227#[cfg(feature = "debug-impls")]
228impl ::core::fmt::Debug for SDL_LogPriority {
229 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
230 #[allow(unreachable_patterns)]
231 f.write_str(match *self {
232 Self::INVALID => "SDL_LOG_PRIORITY_INVALID",
233 Self::TRACE => "SDL_LOG_PRIORITY_TRACE",
234 Self::VERBOSE => "SDL_LOG_PRIORITY_VERBOSE",
235 Self::DEBUG => "SDL_LOG_PRIORITY_DEBUG",
236 Self::INFO => "SDL_LOG_PRIORITY_INFO",
237 Self::WARN => "SDL_LOG_PRIORITY_WARN",
238 Self::ERROR => "SDL_LOG_PRIORITY_ERROR",
239 Self::CRITICAL => "SDL_LOG_PRIORITY_CRITICAL",
240 Self::COUNT => "SDL_LOG_PRIORITY_COUNT",
241
242 _ => return write!(f, "SDL_LogPriority({})", self.0),
243 })
244 }
245}
246
247impl SDL_LogPriority {
248 pub const INVALID: Self = Self((0 as ::core::ffi::c_int));
249 pub const TRACE: Self = Self((1 as ::core::ffi::c_int));
250 pub const VERBOSE: Self = Self((2 as ::core::ffi::c_int));
251 pub const DEBUG: Self = Self((3 as ::core::ffi::c_int));
252 pub const INFO: Self = Self((4 as ::core::ffi::c_int));
253 pub const WARN: Self = Self((5 as ::core::ffi::c_int));
254 pub const ERROR: Self = Self((6 as ::core::ffi::c_int));
255 pub const CRITICAL: Self = Self((7 as ::core::ffi::c_int));
256 pub const COUNT: Self = Self((8 as ::core::ffi::c_int));
257}
258
259pub const SDL_LOG_PRIORITY_INVALID: SDL_LogPriority = SDL_LogPriority::INVALID;
260pub const SDL_LOG_PRIORITY_TRACE: SDL_LogPriority = SDL_LogPriority::TRACE;
261pub const SDL_LOG_PRIORITY_VERBOSE: SDL_LogPriority = SDL_LogPriority::VERBOSE;
262pub const SDL_LOG_PRIORITY_DEBUG: SDL_LogPriority = SDL_LogPriority::DEBUG;
263pub const SDL_LOG_PRIORITY_INFO: SDL_LogPriority = SDL_LogPriority::INFO;
264pub const SDL_LOG_PRIORITY_WARN: SDL_LogPriority = SDL_LogPriority::WARN;
265pub const SDL_LOG_PRIORITY_ERROR: SDL_LogPriority = SDL_LogPriority::ERROR;
266pub const SDL_LOG_PRIORITY_CRITICAL: SDL_LogPriority = SDL_LogPriority::CRITICAL;
267pub const SDL_LOG_PRIORITY_COUNT: SDL_LogPriority = SDL_LogPriority::COUNT;
268
269#[cfg(feature = "metadata")]
270impl sdl3_sys::metadata::GroupMetadata for SDL_LogPriority {
271 const GROUP_METADATA: &'static sdl3_sys::metadata::Group =
272 &crate::metadata::log::METADATA_SDL_LogPriority;
273}
274
275unsafe extern "C" {
276 /// Set the priority of all log categories.
277 ///
278 /// ## Parameters
279 /// - `priority`: the [`SDL_LogPriority`] to assign.
280 ///
281 /// ## Thread safety
282 /// It is safe to call this function from any thread.
283 ///
284 /// ## Availability
285 /// This function is available since SDL 3.2.0.
286 ///
287 /// ## See also
288 /// - [`SDL_ResetLogPriorities`]
289 /// - [`SDL_SetLogPriority`]
290 pub fn SDL_SetLogPriorities(priority: SDL_LogPriority);
291}
292
293unsafe extern "C" {
294 /// Set the priority of a particular log category.
295 ///
296 /// ## Parameters
297 /// - `category`: the category to assign a priority to.
298 /// - `priority`: the [`SDL_LogPriority`] to assign.
299 ///
300 /// ## Thread safety
301 /// It is safe to call this function from any thread.
302 ///
303 /// ## Availability
304 /// This function is available since SDL 3.2.0.
305 ///
306 /// ## See also
307 /// - [`SDL_GetLogPriority`]
308 /// - [`SDL_ResetLogPriorities`]
309 /// - [`SDL_SetLogPriorities`]
310 pub fn SDL_SetLogPriority(category: ::core::ffi::c_int, priority: SDL_LogPriority);
311}
312
313unsafe extern "C" {
314 /// Get the priority of a particular log category.
315 ///
316 /// ## Parameters
317 /// - `category`: the category to query.
318 ///
319 /// ## Return value
320 /// Returns the [`SDL_LogPriority`] for the requested category.
321 ///
322 /// ## Thread safety
323 /// It is safe to call this function from any thread.
324 ///
325 /// ## Availability
326 /// This function is available since SDL 3.2.0.
327 ///
328 /// ## See also
329 /// - [`SDL_SetLogPriority`]
330 pub fn SDL_GetLogPriority(category: ::core::ffi::c_int) -> SDL_LogPriority;
331}
332
333unsafe extern "C" {
334 /// Reset all priorities to default.
335 ///
336 /// This is called by [`SDL_Quit()`].
337 ///
338 /// ## Thread safety
339 /// It is safe to call this function from any thread.
340 ///
341 /// ## Availability
342 /// This function is available since SDL 3.2.0.
343 ///
344 /// ## See also
345 /// - [`SDL_SetLogPriorities`]
346 /// - [`SDL_SetLogPriority`]
347 pub fn SDL_ResetLogPriorities();
348}
349
350unsafe extern "C" {
351 /// Set the text prepended to log messages of a given priority.
352 ///
353 /// By default [`SDL_LOG_PRIORITY_INFO`] and below have no prefix, and
354 /// [`SDL_LOG_PRIORITY_WARN`] and higher have a prefix showing their priority, e.g.
355 /// "WARNING: ".
356 ///
357 /// This function makes a copy of its string argument, **prefix**, so it is not
358 /// necessary to keep the value of **prefix** alive after the call returns.
359 ///
360 /// ## Parameters
361 /// - `priority`: the [`SDL_LogPriority`] to modify.
362 /// - `prefix`: the prefix to use for that log priority, or NULL to use no
363 /// prefix.
364 ///
365 /// ## Return value
366 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
367 /// information.
368 ///
369 /// ## Thread safety
370 /// It is safe to call this function from any thread.
371 ///
372 /// ## Availability
373 /// This function is available since SDL 3.2.0.
374 ///
375 /// ## See also
376 /// - [`SDL_SetLogPriorities`]
377 /// - [`SDL_SetLogPriority`]
378 pub fn SDL_SetLogPriorityPrefix(
379 priority: SDL_LogPriority,
380 prefix: *const ::core::ffi::c_char,
381 ) -> ::core::primitive::bool;
382}
383
384unsafe extern "C" {
385 /// Log a message with [`SDL_LOG_CATEGORY_APPLICATION`] and [`SDL_LOG_PRIORITY_INFO`].
386 ///
387 /// ## Parameters
388 /// - `fmt`: a printf() style message format string.
389 /// - `...`: additional parameters matching % tokens in the `fmt` string, if
390 /// any.
391 ///
392 /// ## Thread safety
393 /// It is safe to call this function from any thread.
394 ///
395 /// ## Availability
396 /// This function is available since SDL 3.2.0.
397 ///
398 /// ## See also
399 /// - [`SDL_LogCritical`]
400 /// - [`SDL_LogDebug`]
401 /// - [`SDL_LogError`]
402 /// - [`SDL_LogInfo`]
403 /// - [`SDL_LogMessage`]
404 /// - [`SDL_LogMessageV`]
405 /// - [`SDL_LogTrace`]
406 /// - [`SDL_LogVerbose`]
407 /// - [`SDL_LogWarn`]
408 pub fn SDL_Log(fmt: *const ::core::ffi::c_char, ...);
409}
410
411unsafe extern "C" {
412 /// Log a message with [`SDL_LOG_PRIORITY_TRACE`].
413 ///
414 /// ## Parameters
415 /// - `category`: the category of the message.
416 /// - `fmt`: a printf() style message format string.
417 /// - `...`: additional parameters matching % tokens in the **fmt** string,
418 /// if any.
419 ///
420 /// ## Thread safety
421 /// It is safe to call this function from any thread.
422 ///
423 /// ## Availability
424 /// This function is available since SDL 3.2.0.
425 ///
426 /// ## See also
427 /// - [`SDL_Log`]
428 /// - [`SDL_LogCritical`]
429 /// - [`SDL_LogDebug`]
430 /// - [`SDL_LogError`]
431 /// - [`SDL_LogInfo`]
432 /// - [`SDL_LogMessage`]
433 /// - [`SDL_LogMessageV`]
434 /// - [`SDL_LogVerbose`]
435 /// - [`SDL_LogWarn`]
436 pub fn SDL_LogTrace(category: ::core::ffi::c_int, fmt: *const ::core::ffi::c_char, ...);
437}
438
439unsafe extern "C" {
440 /// Log a message with [`SDL_LOG_PRIORITY_VERBOSE`].
441 ///
442 /// ## Parameters
443 /// - `category`: the category of the message.
444 /// - `fmt`: a printf() style message format string.
445 /// - `...`: additional parameters matching % tokens in the **fmt** string,
446 /// if any.
447 ///
448 /// ## Thread safety
449 /// It is safe to call this function from any thread.
450 ///
451 /// ## Availability
452 /// This function is available since SDL 3.2.0.
453 ///
454 /// ## See also
455 /// - [`SDL_Log`]
456 /// - [`SDL_LogCritical`]
457 /// - [`SDL_LogDebug`]
458 /// - [`SDL_LogError`]
459 /// - [`SDL_LogInfo`]
460 /// - [`SDL_LogMessage`]
461 /// - [`SDL_LogMessageV`]
462 /// - [`SDL_LogWarn`]
463 pub fn SDL_LogVerbose(category: ::core::ffi::c_int, fmt: *const ::core::ffi::c_char, ...);
464}
465
466unsafe extern "C" {
467 /// Log a message with [`SDL_LOG_PRIORITY_DEBUG`].
468 ///
469 /// ## Parameters
470 /// - `category`: the category of the message.
471 /// - `fmt`: a printf() style message format string.
472 /// - `...`: additional parameters matching % tokens in the **fmt** string,
473 /// if any.
474 ///
475 /// ## Thread safety
476 /// It is safe to call this function from any thread.
477 ///
478 /// ## Availability
479 /// This function is available since SDL 3.2.0.
480 ///
481 /// ## See also
482 /// - [`SDL_Log`]
483 /// - [`SDL_LogCritical`]
484 /// - [`SDL_LogError`]
485 /// - [`SDL_LogInfo`]
486 /// - [`SDL_LogMessage`]
487 /// - [`SDL_LogMessageV`]
488 /// - [`SDL_LogTrace`]
489 /// - [`SDL_LogVerbose`]
490 /// - [`SDL_LogWarn`]
491 pub fn SDL_LogDebug(category: ::core::ffi::c_int, fmt: *const ::core::ffi::c_char, ...);
492}
493
494unsafe extern "C" {
495 /// Log a message with [`SDL_LOG_PRIORITY_INFO`].
496 ///
497 /// ## Parameters
498 /// - `category`: the category of the message.
499 /// - `fmt`: a printf() style message format string.
500 /// - `...`: additional parameters matching % tokens in the **fmt** string,
501 /// if any.
502 ///
503 /// ## Thread safety
504 /// It is safe to call this function from any thread.
505 ///
506 /// ## Availability
507 /// This function is available since SDL 3.2.0.
508 ///
509 /// ## See also
510 /// - [`SDL_Log`]
511 /// - [`SDL_LogCritical`]
512 /// - [`SDL_LogDebug`]
513 /// - [`SDL_LogError`]
514 /// - [`SDL_LogMessage`]
515 /// - [`SDL_LogMessageV`]
516 /// - [`SDL_LogTrace`]
517 /// - [`SDL_LogVerbose`]
518 /// - [`SDL_LogWarn`]
519 pub fn SDL_LogInfo(category: ::core::ffi::c_int, fmt: *const ::core::ffi::c_char, ...);
520}
521
522unsafe extern "C" {
523 /// Log a message with [`SDL_LOG_PRIORITY_WARN`].
524 ///
525 /// ## Parameters
526 /// - `category`: the category of the message.
527 /// - `fmt`: a printf() style message format string.
528 /// - `...`: additional parameters matching % tokens in the **fmt** string,
529 /// if any.
530 ///
531 /// ## Thread safety
532 /// It is safe to call this function from any thread.
533 ///
534 /// ## Availability
535 /// This function is available since SDL 3.2.0.
536 ///
537 /// ## See also
538 /// - [`SDL_Log`]
539 /// - [`SDL_LogCritical`]
540 /// - [`SDL_LogDebug`]
541 /// - [`SDL_LogError`]
542 /// - [`SDL_LogInfo`]
543 /// - [`SDL_LogMessage`]
544 /// - [`SDL_LogMessageV`]
545 /// - [`SDL_LogTrace`]
546 /// - [`SDL_LogVerbose`]
547 pub fn SDL_LogWarn(category: ::core::ffi::c_int, fmt: *const ::core::ffi::c_char, ...);
548}
549
550unsafe extern "C" {
551 /// Log a message with [`SDL_LOG_PRIORITY_ERROR`].
552 ///
553 /// ## Parameters
554 /// - `category`: the category of the message.
555 /// - `fmt`: a printf() style message format string.
556 /// - `...`: additional parameters matching % tokens in the **fmt** string,
557 /// if any.
558 ///
559 /// ## Thread safety
560 /// It is safe to call this function from any thread.
561 ///
562 /// ## Availability
563 /// This function is available since SDL 3.2.0.
564 ///
565 /// ## See also
566 /// - [`SDL_Log`]
567 /// - [`SDL_LogCritical`]
568 /// - [`SDL_LogDebug`]
569 /// - [`SDL_LogInfo`]
570 /// - [`SDL_LogMessage`]
571 /// - [`SDL_LogMessageV`]
572 /// - [`SDL_LogTrace`]
573 /// - [`SDL_LogVerbose`]
574 /// - [`SDL_LogWarn`]
575 pub fn SDL_LogError(category: ::core::ffi::c_int, fmt: *const ::core::ffi::c_char, ...);
576}
577
578unsafe extern "C" {
579 /// Log a message with [`SDL_LOG_PRIORITY_CRITICAL`].
580 ///
581 /// ## Parameters
582 /// - `category`: the category of the message.
583 /// - `fmt`: a printf() style message format string.
584 /// - `...`: additional parameters matching % tokens in the **fmt** string,
585 /// if any.
586 ///
587 /// ## Thread safety
588 /// It is safe to call this function from any thread.
589 ///
590 /// ## Availability
591 /// This function is available since SDL 3.2.0.
592 ///
593 /// ## See also
594 /// - [`SDL_Log`]
595 /// - [`SDL_LogDebug`]
596 /// - [`SDL_LogError`]
597 /// - [`SDL_LogInfo`]
598 /// - [`SDL_LogMessage`]
599 /// - [`SDL_LogMessageV`]
600 /// - [`SDL_LogTrace`]
601 /// - [`SDL_LogVerbose`]
602 /// - [`SDL_LogWarn`]
603 pub fn SDL_LogCritical(category: ::core::ffi::c_int, fmt: *const ::core::ffi::c_char, ...);
604}
605
606unsafe extern "C" {
607 /// Log a message with the specified category and priority.
608 ///
609 /// ## Parameters
610 /// - `category`: the category of the message.
611 /// - `priority`: the priority of the message.
612 /// - `fmt`: a printf() style message format string.
613 /// - `...`: additional parameters matching % tokens in the **fmt** string,
614 /// if any.
615 ///
616 /// ## Thread safety
617 /// It is safe to call this function from any thread.
618 ///
619 /// ## Availability
620 /// This function is available since SDL 3.2.0.
621 ///
622 /// ## See also
623 /// - [`SDL_Log`]
624 /// - [`SDL_LogCritical`]
625 /// - [`SDL_LogDebug`]
626 /// - [`SDL_LogError`]
627 /// - [`SDL_LogInfo`]
628 /// - [`SDL_LogMessageV`]
629 /// - [`SDL_LogTrace`]
630 /// - [`SDL_LogVerbose`]
631 /// - [`SDL_LogWarn`]
632 pub fn SDL_LogMessage(
633 category: ::core::ffi::c_int,
634 priority: SDL_LogPriority,
635 fmt: *const ::core::ffi::c_char,
636 ...
637 );
638}
639
640unsafe extern "C" {
641 /// Log a message with the specified category and priority.
642 ///
643 /// ## Parameters
644 /// - `category`: the category of the message.
645 /// - `priority`: the priority of the message.
646 /// - `fmt`: a printf() style message format string.
647 /// - `ap`: a variable argument list.
648 ///
649 /// ## Thread safety
650 /// It is safe to call this function from any thread.
651 ///
652 /// ## Availability
653 /// This function is available since SDL 3.2.0.
654 ///
655 /// ## See also
656 /// - [`SDL_Log`]
657 /// - [`SDL_LogCritical`]
658 /// - [`SDL_LogDebug`]
659 /// - [`SDL_LogError`]
660 /// - [`SDL_LogInfo`]
661 /// - [`SDL_LogMessage`]
662 /// - [`SDL_LogTrace`]
663 /// - [`SDL_LogVerbose`]
664 /// - [`SDL_LogWarn`]
665 pub fn SDL_LogMessageV(
666 category: ::core::ffi::c_int,
667 priority: SDL_LogPriority,
668 fmt: *const ::core::ffi::c_char,
669 ap: crate::ffi::VaList,
670 );
671}
672
673/// The prototype for the log output callback function.
674///
675/// This function is called by SDL when there is new text to be logged. A mutex
676/// is held so that this function is never called by more than one thread at
677/// once.
678///
679/// ## Parameters
680/// - `userdata`: what was passed as `userdata` to
681/// [`SDL_SetLogOutputFunction()`].
682/// - `category`: the category of the message.
683/// - `priority`: the priority of the message.
684/// - `message`: the message being output.
685///
686/// ## Availability
687/// This datatype is available since SDL 3.2.0.
688pub type SDL_LogOutputFunction = ::core::option::Option<
689 unsafe extern "C" fn(
690 userdata: *mut ::core::ffi::c_void,
691 category: ::core::ffi::c_int,
692 priority: SDL_LogPriority,
693 message: *const ::core::ffi::c_char,
694 ),
695>;
696
697unsafe extern "C" {
698 /// Get the default log output function.
699 ///
700 /// ## Return value
701 /// Returns the default log output callback.
702 ///
703 /// ## Thread safety
704 /// It is safe to call this function from any thread.
705 ///
706 /// ## Availability
707 /// This function is available since SDL 3.2.0.
708 ///
709 /// ## See also
710 /// - [`SDL_SetLogOutputFunction`]
711 /// - [`SDL_GetLogOutputFunction`]
712 pub fn SDL_GetDefaultLogOutputFunction() -> SDL_LogOutputFunction;
713}
714
715unsafe extern "C" {
716 /// Get the current log output function.
717 ///
718 /// ## Parameters
719 /// - `callback`: an [`SDL_LogOutputFunction`] filled in with the current log
720 /// callback.
721 /// - `userdata`: a pointer filled in with the pointer that is passed to
722 /// `callback`.
723 ///
724 /// ## Thread safety
725 /// It is safe to call this function from any thread.
726 ///
727 /// ## Availability
728 /// This function is available since SDL 3.2.0.
729 ///
730 /// ## See also
731 /// - [`SDL_GetDefaultLogOutputFunction`]
732 /// - [`SDL_SetLogOutputFunction`]
733 pub fn SDL_GetLogOutputFunction(
734 callback: *mut SDL_LogOutputFunction,
735 userdata: *mut *mut ::core::ffi::c_void,
736 );
737}
738
739unsafe extern "C" {
740 /// Replace the default log output function with one of your own.
741 ///
742 /// ## Parameters
743 /// - `callback`: an [`SDL_LogOutputFunction`] to call instead of the default.
744 /// - `userdata`: a pointer that is passed to `callback`.
745 ///
746 /// ## Thread safety
747 /// It is safe to call this function from any thread.
748 ///
749 /// ## Availability
750 /// This function is available since SDL 3.2.0.
751 ///
752 /// ## See also
753 /// - [`SDL_GetDefaultLogOutputFunction`]
754 /// - [`SDL_GetLogOutputFunction`]
755 pub fn SDL_SetLogOutputFunction(
756 callback: SDL_LogOutputFunction,
757 userdata: *mut ::core::ffi::c_void,
758 );
759}
760
761#[cfg(doc)]
762use crate::everything::*;