Add sanity checks to output plugins / Add config option FLOG_CONFIG_MSG_ID_STRINGS_EX...
[flog.git] / flog_msg_id.h
blobf38e1cab5ade194f55fa7344ac8bc6ad106f66ad
1 //! Flog - Message ID definitions for the F logging library
3 //! @file flog_msg_id.h
4 //! @author Nabeel Sowan (nabeel.sowan@vibes.se)
5 //!
6 //! Useful for saving space on embedded systems, performance etc.
7 //! if FLOG_NO_MSG_ID_STRINGS is defined then the static string
8 //! data will not be included. This can be used for deeply embedded
9 //! systems where string generation isn't strictly necessary,
10 //! and can be decoded by the receiver.
13 #ifndef FLOG_MSG_ID_H
14 #define FLOG_MSG_ID_H
16 #include "config.h"
18 //! Amount of msg_id entries reserved for passing errno values
19 //! @todo make configurable, move out
20 #define FLOG_MSG_ID_AMOUNT_RESERVED_FOR_ERRNO 8000
23 //! Built in message ids, these are used internally by flog
24 #define FLOG_MSG_IDS_BUILTIN \
25 X(FLOG_MSG_MARK, "Mark" ) \
26 X(FLOG_MSG_ASSERTION_FAILED, "Assertion failed" ) \
27 X(FLOG_MSG_FUNCTION_START, "Function start" ) \
28 X(FLOG_MSG_FUNCTION_END, "Function end" )
31 //! Extended message ids, useful but not entirely necessary
32 #ifdef FLOG_CONFIG_MSG_ID_STRINGS_EXTENDED
33 #define FLOG_MSG_IDS_EXTENDED \
34 X(FLOG_MSG_CANNOT_READ_FROM_STDIN, "Cannot read from stdin") \
35 X(FLOG_MSG_CANNOT_READ_FILE, "Cannot read from file" ) \
36 X(FLOG_MSG_CANNOT_OPEN_SOCKET, "Cannot open socket" )
37 #else
38 #define FLOG_MSG_IDS_EXTENDED
39 #endif
42 //! Message ids for stdio output module
43 #if defined(FLOG_CONFIG_OUTPUT_STDIO) || defined(FLOG_CONFIG_MSG_ID_STRINGS_EXTENDED)
44 #define FLOG_MSG_IDS_OUTPUT_STDIO \
45 X(FLOG_MSG_CANNOT_WRITE_TO_STDOUT, "Cannot write to stdout") \
46 X(FLOG_MSG_CANNOT_WRITE_TO_STDERR, "Cannot write to stderr")
47 #else
48 #define FLOG_MSG_IDS_OUTPUT_STDIO
49 #endif
52 //! Message ids for file output module
53 #if defined(FLOG_CONFIG_OUTPUT_FILE) || defined(FLOG_CONFIG_MSG_ID_STRINGS_EXTENDED)
54 #define FLOG_MSG_IDS_OUTPUT_FILE \
55 X(FLOG_MSG_CANNOT_OPEN_FILE, "Cannot open file" ) \
56 X(FLOG_MSG_CANNOT_WRITE_FILE, "Cannot write to file" ) \
57 X(FLOG_MSG_SET_OUTPUT_FILE, "Please set output file")
58 #else
59 #define FLOG_MSG_IDS_OUTPUT_FILE
60 #endif
63 // Custom message ids, if they are not defined, define to null
64 #ifndef FLOG_MSG_IDS_CUSTOM
65 #define FLOG_MSG_IDS_CUSTOM
66 #endif
69 //! List of message id lists to be used
70 #define FLOG_MSG_IDS \
71 FLOG_MSG_IDS_BUILTIN \
72 FLOG_MSG_IDS_EXTENDED \
73 FLOG_MSG_IDS_OUTPUT_STDIO \
74 FLOG_MSG_IDS_OUTPUT_FILE \
75 FLOG_MSG_IDS_CUSTOM
78 #define X(id, str) id,
79 typedef enum {
80 FLOG_MSG_NONE = 0,
81 FLOG_MSG_ID_LOWERBOUND = (FLOG_MSG_ID_AMOUNT_RESERVED_FOR_ERRNO-1),
82 FLOG_MSG_IDS
83 FLOG_MSG_ID_AMOUNT
84 } FLOG_MSG_ID_T;
85 #undef X
88 #endif //FLOG_MSG_ID_H