-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathexample_inline.c
More file actions
93 lines (81 loc) · 1.9 KB
/
example_inline.c
File metadata and controls
93 lines (81 loc) · 1.9 KB
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
/**
* \file example_inline.c
*
* \brief Example usage of inline logging functions from c_traceback library
*/
#include <stdio.h>
#include <string.h>
#include "c_traceback.h"
#define MESSAGE_BUFFER_SIZE 256
void inline_error(int i);
void inline_error_level2(int i);
void inline_warning(int i);
void inline_warning_level2(int i);
void inline_message(int i);
void inline_message_level2(int i);
int main(void)
{
inline_error(1);
inline_warning(3);
inline_message(5);
return 0;
}
void inline_error(int i)
{
LOG_ERROR_INLINE_FMT(
CTB_MATH_ERROR,
"(Test %d) This should be inline formatted error level 1 with math error",
i
);
inline_error_level2(i + 1);
}
void inline_error_level2(int i)
{
char message[MESSAGE_BUFFER_SIZE];
snprintf(
message,
MESSAGE_BUFFER_SIZE,
"(Test %d) This should be inline error level 2 with buffer error",
i
);
LOG_ERROR_INLINE(CTB_BUFFER_ERROR, message);
}
void inline_warning(int i)
{
LOG_WARNING_INLINE_FMT(
CTB_DEPRECATION_WARNING,
"(Test %d) This should be inline formatted warning level 1 with deprecation "
"warning",
i
);
inline_warning_level2(i + 1);
}
void inline_warning_level2(int i)
{
char message[MESSAGE_BUFFER_SIZE];
snprintf(
message,
MESSAGE_BUFFER_SIZE,
"(Test %d) This should be inline warning level 2 with user warning",
i
);
LOG_WARNING_INLINE(CTB_USER_WARNING, message);
}
void inline_message(int i)
{
LOG_MESSAGE_INLINE_FMT(
"(Test %d) This should be inline formatted message level 1", i
);
inline_message_level2(i + 1);
}
void inline_message_level2(int i)
{
char message[MESSAGE_BUFFER_SIZE];
snprintf(
message,
MESSAGE_BUFFER_SIZE,
"(Test %d) This should be inline message level 2",
i
);
LOG_MESSAGE_INLINE(message);
}