Mercurial > molko
comparison libmlk-core/mlk/core/trace.h @ 541:970cad994a95
core: doxygenize trace
author | David Demelier <markand@malikania.fr> |
---|---|
date | Sun, 05 Mar 2023 13:02:07 +0100 |
parents | 6e8f6640e05b |
children |
comparison
equal
deleted
inserted
replaced
540:876eee0eb0ad | 541:970cad994a95 |
---|---|
17 */ | 17 */ |
18 | 18 |
19 #ifndef MLK_CORE_TRACE_H | 19 #ifndef MLK_CORE_TRACE_H |
20 #define MLK_CORE_TRACE_H | 20 #define MLK_CORE_TRACE_H |
21 | 21 |
22 /** | |
23 * \file mlk/core/trace.h | |
24 * \brief Non-fatal message logs | |
25 * | |
26 * This module provides a simple way to log messages from the API or user code, | |
27 * mostly when non-fatal errors happened. | |
28 * | |
29 * The default implementation uses printf with a timestamp in the form hh:mm::s | |
30 * to the standard output, it can be disabled using your own | |
31 * ::mlk_trace_handler or setting it to NULL. | |
32 * | |
33 * Example of lines generated by default: | |
34 * | |
35 * ``` | |
36 * 10:20:30: hello world | |
37 * 20:50:00: goodbye world | |
38 * ``` | |
39 */ | |
40 | |
22 #include <stdarg.h> | 41 #include <stdarg.h> |
23 | 42 |
24 #define TRACE_LINE_MAX (1024) | 43 /** |
44 * Maximum trace line | |
45 */ | |
46 #define MLK_TRACE_LINE_MAX (128) | |
25 | 47 |
26 extern void (*mlk_trace_handler)(const char *); | 48 /** |
49 * Default trace handler implementation | |
50 * | |
51 * Can be set to NULL to disable logging. | |
52 * | |
53 * \param line the line to print | |
54 */ | |
55 extern void (*mlk_trace_handler)(const char *line); | |
27 | 56 |
28 #if defined(__cplusplus) | 57 #if defined(__cplusplus) |
29 extern "C" { | 58 extern "C" { |
30 #endif | 59 #endif |
31 | 60 |
61 /** | |
62 * Write a trace log using a [printf] format style. | |
63 * | |
64 * [printf]: https://en.cppreference.com/w/c/io/fprintf | |
65 * | |
66 * \pre fmt != NULL | |
67 * \param fmt the printf format string | |
68 */ | |
32 void | 69 void |
33 mlk_tracef(const char *, ...); | 70 mlk_tracef(const char *fmt, ...); |
34 | 71 |
72 /** | |
73 * Similar to ::mlk_tracef but using a `va_list` instead. | |
74 * | |
75 * \pre fmt != NULL | |
76 * \param fmt the printf format string | |
77 * \param ap the variadic handle | |
78 */ | |
35 void | 79 void |
36 mlk_traceva(const char *, va_list); | 80 mlk_traceva(const char *fmt, va_list ap); |
37 | 81 |
38 #if defined(__cplusplus) | 82 #if defined(__cplusplus) |
39 } | 83 } |
40 #endif | 84 #endif |
41 | 85 |