Brian Silverman | fd5e2a3 | 2014-02-22 20:02:39 -0800 | [diff] [blame^] | 1 | #ifndef AOS_COMMON_LOGGING_MATRIX_LOGGING_H_ |
| 2 | #define AOS_COMMON_LOGGING_MATRIX_LOGGING_H_ |
| 3 | |
| 4 | #include <string> |
| 5 | |
| 6 | #include "Eigen/Dense" |
| 7 | |
| 8 | #include "aos/common/logging/logging.h" |
| 9 | #include "aos/common/die.h" |
| 10 | |
| 11 | namespace aos { |
| 12 | namespace logging { |
| 13 | |
| 14 | // Logs the contents of a matrix and a constant string. |
| 15 | // matrix must be an instance of an Eigen matrix (or something similar). |
| 16 | #define LOG_MATRIX(level, message, matrix) \ |
| 17 | do { \ |
| 18 | static const ::std::string kAosLoggingMessage( \ |
| 19 | LOG_SOURCENAME ": " STRINGIFY(__LINE__) ": " message); \ |
| 20 | ::aos::logging::DoLogMatrix(level, kAosLoggingMessage, matrix); \ |
| 21 | /* so that GCC knows that it won't return */ \ |
| 22 | if (level == FATAL) { \ |
| 23 | ::aos::Die("DoLogStruct(FATAL) fell through!!!!!\n"); \ |
| 24 | } \ |
| 25 | } while (false) |
| 26 | |
| 27 | template <class T> |
| 28 | void DoLogMatrix(log_level level, const ::std::string &message, |
| 29 | const T &matrix); |
| 30 | |
| 31 | } // namespace logging |
| 32 | } // namespace aos |
| 33 | |
| 34 | #include "aos/common/logging/matrix_logging-tmpl.h" |
| 35 | |
| 36 | #endif // AOS_COMMON_LOGGING_MATRIX_LOGGING_H_ |