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" |
Brian Silverman | fd5e2a3 | 2014-02-22 20:02:39 -0800 | [diff] [blame^] | 10 | #include "aos/common/die.h" |
Brian Silverman | d6974f4 | 2014-02-14 13:39:21 -0800 | [diff] [blame] | 11 | |
| 12 | namespace aos { |
| 13 | namespace logging { |
| 14 | |
Brian Silverman | fd5e2a3 | 2014-02-22 20:02:39 -0800 | [diff] [blame^] | 15 | // Logs the contents of a structure (or Queue message) and a constant string. |
| 16 | // structure must be an instance of one of the generated queue types. |
Brian Silverman | d6974f4 | 2014-02-14 13:39:21 -0800 | [diff] [blame] | 17 | #define LOG_STRUCT(level, message, structure) \ |
| 18 | do { \ |
| 19 | static const ::std::string kAosLoggingMessage( \ |
| 20 | LOG_SOURCENAME ": " STRINGIFY(__LINE__) ": " message); \ |
| 21 | ::aos::logging::DoLogStruct(level, kAosLoggingMessage, structure); \ |
| 22 | /* so that GCC knows that it won't return */ \ |
| 23 | if (level == FATAL) { \ |
Brian Silverman | fd5e2a3 | 2014-02-22 20:02:39 -0800 | [diff] [blame^] | 24 | ::aos::Die("DoLogStruct(FATAL) fell through!!!!!\n"); \ |
Brian Silverman | d6974f4 | 2014-02-14 13:39:21 -0800 | [diff] [blame] | 25 | } \ |
| 26 | } while (false) |
Brian Silverman | d6974f4 | 2014-02-14 13:39:21 -0800 | [diff] [blame] | 27 | |
| 28 | template <class T> |
| 29 | void DoLogStruct(log_level level, const ::std::string &message, |
| 30 | const T &structure); |
| 31 | |
| 32 | } // namespace logging |
| 33 | } // namespace aos |
| 34 | |
| 35 | #include "aos/common/logging/queue_logging-tmpl.h" |
| 36 | |
| 37 | #endif // AOS_COMMON_LOGGING_QUEUE_LOGGING_H_ |