Statistics
| Branch: | Tag: | Revision:

amiro-os / include / amiro / debug.h @ e2002d0e

History | View | Annotate | Download (2.271 KB)

1 58fe0e0b Thomas Schöpping
#ifndef AMIRO_DEBUG_H_
2
#define AMIRO_DEBUG_H
3
4
#include <amiroosconf.h>
5
#include <chprintf.h>
6
#include <chdebug.h>
7
8
9
10
/**
11
 * @brief Simple message printing macro
12
 *
13
 * @param[in] fmt     the string message to print
14
 * @param[in] args... the optional list of arguments to insert in the message
15
 *
16
 * @todo Make output stream adjustable
17
 */
18
#define amiroPrintf(fmt, args...) {                   \
19
  chprintf((BaseSequentialStream*)&SD1, fmt, ##args); \
20
}
21
22
#if AMIRO_DBG || defined(__DOXYGEN__)
23
24
/**
25
 * @brief Macro to print an error
26
 *
27
 * @param[in] c       the condition to be verified to be true
28
 * @param[in] msg     the string message to print
29
 * @param[in] args... the optional list of arguments to insert in the message
30
 */
31
#define amiroDbgError(c, msg, args...) {                                     \
32
  if (!(c))                                                                  \
33
    amiroPrintf("ERROR: " msg "\tAT %s:%s()\n", ##args, __FILE__, __func__); \
34
}
35
36
/**
37
 * @brief Macro to print a warning
38
 *
39
 * @param[in] c       the condition to be verified to be true
40
 * @param[in] msg     the text message
41
 * @param[in] args... the optional list of arguments to insert in the message
42
 */
43
#define amiroDbgWarning(c, msg, args...) {                                      \
44
  if (!(c))                                                                     \
45
    amiroPrintf("WARNING: " msg "\tAT: %s:%s()\n", ##args, __FILE__, __func__); \
46
}
47
48
/**
49
 * @brief Macro to print a note
50
 *
51
 * @param[in] msg     the text message
52
 * @param[in] args... the optional list of arguments to insert in the message
53
 */
54
#define amiroDbgNote(msg, args...) {                                       \
55
  amiroPrintf("NOTE: " msg "\tAT: %s:%s()\n", ##args, __FILE__, __func__); \
56
}
57
58
/**
59
 * @brief Macro to print a todo
60
 *
61
 * @param[in] msg     the text message
62
 * @param[in] args... the optional list of arguments to insert in the message
63
 */
64
#define amiroDbgTodo(msg, args...) {                                       \
65
  amiroPrintf("TODO: " msg "\tAT: %s:%s()\n", ##args, __FILE__, __func__); \
66
}
67
68
#else
69
70
/*
71
 * empty macro definitions, if AMIRO_DBG is FALSE
72
 */
73
#define amiroDbgError(c, msg, args...)
74
#define amiroDbgWarning(c, msg, args...)
75
#define amiroDbgNote(msg, args...)
76
#define amiroDbgTodo(msg, args...)
77
78
#endif
79
80
81
#endif // AMIRO_DEBUG_H_