blob: 6efaa06f5341e67239648f8c69ca73d6f4a225d6 [file] [log] [blame]
Brian Silvermanfd5e2a32014-02-22 20:02:39 -08001#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
11namespace aos {
12namespace 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
27template <class T>
28void 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_