Brian Silverman | d6974f4 | 2014-02-14 13:39:21 -0800 | [diff] [blame^] | 1 | #ifndef AOS_COMMON_LOGGING_QUEUE_LOGGING_H_ |
| 2 | #define AOS_COMMON_LOGGING_QUEUE_LOGGING_H_ |
| 3 | |
| 4 | #include <stdio.h> |
| 5 | #include <stdlib.h> |
| 6 | |
| 7 | #include <string> |
| 8 | |
| 9 | #include "aos/common/logging/logging.h" |
| 10 | |
| 11 | namespace aos { |
| 12 | namespace logging { |
| 13 | |
| 14 | #define LOG_STRUCT(level, message, structure) \ |
| 15 | do { \ |
| 16 | static const ::std::string kAosLoggingMessage( \ |
| 17 | LOG_SOURCENAME ": " STRINGIFY(__LINE__) ": " message); \ |
| 18 | ::aos::logging::DoLogStruct(level, kAosLoggingMessage, structure); \ |
| 19 | /* so that GCC knows that it won't return */ \ |
| 20 | if (level == FATAL) { \ |
| 21 | fprintf(stderr, "DoLogStruct(FATAL) fell through!!!!!\n"); \ |
| 22 | printf("see stderr\n"); \ |
| 23 | abort(); \ |
| 24 | } \ |
| 25 | } while (false) |
| 26 | |
| 27 | template <class T> |
| 28 | void DoLogStruct(log_level level, const ::std::string &message, |
| 29 | const T &structure); |
| 30 | |
| 31 | } // namespace logging |
| 32 | } // namespace aos |
| 33 | |
| 34 | #include "aos/common/logging/queue_logging-tmpl.h" |
| 35 | |
| 36 | #endif // AOS_COMMON_LOGGING_QUEUE_LOGGING_H_ |