Brian Silverman | fd5e2a3 | 2014-02-22 20:02:39 -0800 | [diff] [blame] | 1 | #include "aos/common/logging/matrix_logging.h" |
Brian Silverman | ff12c9f | 2014-03-19 17:53:29 -0700 | [diff] [blame^] | 2 | |
| 3 | #include "aos/common/queue_types.h" |
| 4 | |
| 5 | namespace aos { |
| 6 | namespace logging { |
| 7 | |
| 8 | void LogImplementation::DoLogMatrix(log_level level, |
| 9 | const ::std::string &message, |
| 10 | uint32_t type_id, int rows, int cols, |
| 11 | const void *data, int levels) { |
| 12 | internal::RunWithCurrentImplementation( |
| 13 | levels, [&](LogImplementation * implementation) { |
| 14 | implementation->LogMatrix(level, message, type_id, rows, cols, data); |
| 15 | }); |
| 16 | |
| 17 | if (level == FATAL) { |
| 18 | char serialized[1024]; |
| 19 | if (static_cast<size_t>(rows * cols * MessageType::Sizeof(type_id)) > |
| 20 | sizeof(serialized)) { |
| 21 | Die("LOG(FATAL) matrix too big to serialize"); |
| 22 | } |
| 23 | SerializeMatrix(type_id, serialized, data, rows, cols); |
| 24 | char printed[LOG_MESSAGE_LEN]; |
| 25 | size_t printed_bytes = sizeof(printed); |
| 26 | if (!PrintMatrix(printed, &printed_bytes, serialized, type_id, rows, cols)) { |
| 27 | Die("LOG(FATAL) PrintMatrix call failed"); |
| 28 | } |
| 29 | Die("%.*s: %.*s\n", static_cast<int>(message.size()), message.data(), |
| 30 | static_cast<int>(printed_bytes), printed); |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | } // namespace logging |
| 35 | } // namespace aos |