brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 1 | #include <stdio.h> |
| 2 | #include <stdlib.h> |
| 3 | #include <getopt.h> |
| 4 | #include <sys/types.h> |
| 5 | #include <sys/stat.h> |
| 6 | #include <fcntl.h> |
| 7 | #include <inttypes.h> |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 8 | |
Brian Silverman | 88471dc | 2014-02-15 22:35:42 -0800 | [diff] [blame] | 9 | #include <algorithm> |
Daniel Petti | b6c885b | 2014-09-12 10:04:28 -0700 | [diff] [blame] | 10 | #include <memory> |
| 11 | #include <string> |
Brian Silverman | 88471dc | 2014-02-15 22:35:42 -0800 | [diff] [blame] | 12 | |
Brian Silverman | fe9b7a2 | 2014-02-10 15:03:42 -0800 | [diff] [blame] | 13 | #include "aos/linux_code/logging/binary_log_file.h" |
Brian Silverman | 88471dc | 2014-02-15 22:35:42 -0800 | [diff] [blame] | 14 | #include "aos/common/queue_types.h" |
Brian Silverman | a7234c6 | 2014-03-24 20:23:25 -0700 | [diff] [blame] | 15 | #include "aos/common/logging/logging_impl.h" |
| 16 | #include "aos/common/logging/logging_printf_formats.h" |
Daniel Petti | b6c885b | 2014-09-12 10:04:28 -0700 | [diff] [blame] | 17 | #include "aos/common/util/string_to_num.h" |
Brian Silverman | 88471dc | 2014-02-15 22:35:42 -0800 | [diff] [blame] | 18 | |
| 19 | using ::aos::logging::linux_code::LogFileMessageHeader; |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 20 | |
| 21 | namespace { |
| 22 | |
| 23 | const char *kArgsHelp = "[OPTION]... [FILE]\n" |
| 24 | "Display log file FILE (created by BinaryLogReader) to stdout.\n" |
| 25 | "FILE is \"aos_log-current\" by default.\n" |
Brian Silverman | 65e569d | 2014-10-24 15:43:20 -0400 | [diff] [blame^] | 26 | "FILE can also be \"-\" to read from standard input.\n" |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 27 | "\n" |
| 28 | " -n, --name NAME only display entries from processes named NAME\n" |
| 29 | " -l, --level LEVEL " |
| 30 | "only display log entries at least as important as LEVEL\n" |
Daniel Petti | b6c885b | 2014-09-12 10:04:28 -0700 | [diff] [blame] | 31 | " -p, --pid PID only display log entries from process PID\n" |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 32 | " -f, --follow " |
| 33 | "wait when the end of the file is reached (implies --end)\n" |
| 34 | " -t, --terminate stop when the end of file is reached (default)\n" |
| 35 | " -b, --beginning start at the beginning of the file (default)\n" |
| 36 | " -e, --end start at the end of the file\n" |
| 37 | " -s, --skip NUMBER skip NUMBER matching logs\n" |
Daniel Petti | b6c885b | 2014-09-12 10:04:28 -0700 | [diff] [blame] | 38 | " -m, --max NUMBER only display up to NUMBER logs\n" |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 39 | " // -o, --format FORMAT use FORMAT to display log entries\n" |
Brian Silverman | a52ba16 | 2013-02-28 15:01:12 -0800 | [diff] [blame] | 40 | " -h, --help display this help and exit\n" |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 41 | "\n" |
| 42 | "LEVEL must be DEBUG, INFO, WARNING, ERROR, or FATAL.\n" |
| 43 | " It defaults to INFO.\n" |
| 44 | "\n" |
Daniel Petti | e6f33e2 | 2014-08-21 20:35:55 -0700 | [diff] [blame] | 45 | "TODO(brians) implement the commented out ones.\n"; |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 46 | |
Daniel Petti | 88c81f4 | 2014-09-12 10:05:05 -0700 | [diff] [blame] | 47 | const char *kExampleUsages = "To view logs from the shooter:\n" |
| 48 | "\t`log_displayer -n shooter`\n" |
| 49 | "To view debug logs from the shooter:\n" |
| 50 | "\t`log_displayer -n shooter -l DEBUG`\n" |
| 51 | "To view what the shooter is logging in realtime:\n" |
| 52 | "\t`log_displayer -f -n shooter`\n" |
| 53 | "To view shooter logs from an old log file:\n" |
| 54 | "\t`log_displayer aos_log-<number> -n shooter`\n" |
| 55 | "To view the statuses of the shooter hall effects in realtime:\n" |
| 56 | "\t`log_displayer -f -n shooter -l DEBUG | grep .Position`\n"; |
| 57 | |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 58 | void PrintHelpAndExit() { |
| 59 | fprintf(stderr, "Usage: %s %s", program_invocation_name, kArgsHelp); |
Daniel Petti | 88c81f4 | 2014-09-12 10:05:05 -0700 | [diff] [blame] | 60 | fprintf(stderr, "\nExample usages:\n\n%s", kExampleUsages); |
| 61 | |
| 62 | // Get the possible executables from start_list.txt. |
| 63 | FILE *start_list = fopen("start_list.txt", "r"); |
| 64 | if (start_list == NULL) { |
| 65 | PLOG(FATAL, "Unable to open start_list.txt"); |
| 66 | } |
| 67 | |
| 68 | // Get file size. |
| 69 | if (fseek(start_list, 0, SEEK_END)) { |
| 70 | PLOG(FATAL, "fseek() failed while reading start_list.txt"); |
| 71 | } |
| 72 | int size = ftell(start_list); |
| 73 | if (size < 0) { |
| 74 | PLOG(FATAL, "ftell() failed while reading start_list.txt"); |
| 75 | } |
| 76 | rewind(start_list); |
| 77 | |
| 78 | ::std::unique_ptr<char[]> contents(new char[size + 1]); |
| 79 | if (contents == NULL) { |
| 80 | LOG(FATAL, "malloc() failed while reading start_list.txt.\n"); |
| 81 | } |
| 82 | size_t bytes_read = fread(contents.get(), 1, size, start_list); |
| 83 | if (bytes_read < static_cast<size_t>(size)) { |
| 84 | LOG(FATAL, "Read %zu bytes from start_list.txt, expected %d.\n", |
| 85 | bytes_read, size); |
| 86 | } |
| 87 | |
| 88 | // printf doesn't like strings without the \0. |
| 89 | contents[size] = '\0'; |
| 90 | fprintf(stderr, "\nPossible arguments for the -n option:\n%s", contents.get()); |
| 91 | |
| 92 | if (fclose(start_list)) { |
| 93 | LOG(FATAL, "fclose() failed.\n"); |
| 94 | } |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 95 | |
| 96 | exit(EXIT_SUCCESS); |
| 97 | } |
| 98 | |
| 99 | } // namespace |
| 100 | |
| 101 | int main(int argc, char **argv) { |
| 102 | const char *filter_name = NULL; |
Brian Silverman | f778031 | 2014-02-16 17:26:15 -0800 | [diff] [blame] | 103 | size_t filter_length = 0; |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 104 | log_level filter_level = INFO; |
Brian Silverman | f778031 | 2014-02-16 17:26:15 -0800 | [diff] [blame] | 105 | bool follow = false; |
| 106 | // Whether we need to skip everything until we get to the end of the file. |
| 107 | bool skip_to_end = false; |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 108 | const char *filename = "aos_log-current"; |
Daniel Petti | b6c885b | 2014-09-12 10:04:28 -0700 | [diff] [blame] | 109 | int display_max = 0; |
| 110 | int32_t source_pid = -1; |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 111 | |
Brian Silverman | ff48578 | 2014-06-18 19:59:09 -0700 | [diff] [blame] | 112 | ::aos::logging::Init(); |
Brian Silverman | f778031 | 2014-02-16 17:26:15 -0800 | [diff] [blame] | 113 | ::aos::logging::AddImplementation( |
| 114 | new ::aos::logging::StreamLogImplementation(stdout)); |
| 115 | |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 116 | while (true) { |
| 117 | static struct option long_options[] = { |
| 118 | {"name", required_argument, NULL, 'n'}, |
| 119 | {"level", required_argument, NULL, 'l'}, |
| 120 | {"pid", required_argument, NULL, 'p'}, |
| 121 | |
| 122 | {"follow", no_argument, NULL, 'f'}, |
| 123 | {"terminate", no_argument, NULL, 't'}, |
| 124 | {"beginning", no_argument, NULL, 'b'}, |
| 125 | {"end", no_argument, NULL, 'e'}, |
| 126 | {"skip", required_argument, NULL, 's'}, |
| 127 | {"max", required_argument, NULL, 'm'}, |
| 128 | |
| 129 | {"format", required_argument, NULL, 'o'}, |
| 130 | |
| 131 | {"help", no_argument, NULL, 'h'}, |
| 132 | {0, 0, 0, 0} |
| 133 | }; |
| 134 | int option_index = 0; |
| 135 | |
| 136 | const int c = getopt_long(argc, argv, "n:l:p:fts:m:o:h", |
| 137 | long_options, &option_index); |
| 138 | if (c == -1) { // if we're at the end |
| 139 | break; |
| 140 | } |
| 141 | switch (c) { |
| 142 | case 0: |
Daniel Petti | 88c81f4 | 2014-09-12 10:05:05 -0700 | [diff] [blame] | 143 | fputs("LogDisplayer: got a 0 option but didn't set up any\n", stderr); |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 144 | abort(); |
| 145 | case 'n': |
| 146 | filter_name = optarg; |
Brian Silverman | 88471dc | 2014-02-15 22:35:42 -0800 | [diff] [blame] | 147 | filter_length = strlen(filter_name); |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 148 | break; |
| 149 | case 'l': |
Brian Silverman | ab6615c | 2013-03-05 20:29:29 -0800 | [diff] [blame] | 150 | filter_level = ::aos::logging::str_log(optarg); |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 151 | if (filter_level == LOG_UNKNOWN) { |
| 152 | fprintf(stderr, "LogDisplayer: unknown log level '%s'\n", optarg); |
| 153 | exit(EXIT_FAILURE); |
| 154 | } |
| 155 | break; |
| 156 | case 'p': |
Daniel Petti | b6c885b | 2014-09-12 10:04:28 -0700 | [diff] [blame] | 157 | if (!::aos::util::StringToInteger(::std::string(optarg), &source_pid)) { |
| 158 | fprintf(stderr, "ERROR: -p expects a number, not '%s'.\n", optarg); |
| 159 | exit(EXIT_FAILURE); |
| 160 | } |
| 161 | if (source_pid < 0) { |
| 162 | fprintf(stderr, "LogDisplayer: invalid pid '%s'\n", optarg); |
| 163 | exit(EXIT_FAILURE); |
| 164 | } |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 165 | break; |
| 166 | case 'f': |
| 167 | follow = true; |
Brian Silverman | f778031 | 2014-02-16 17:26:15 -0800 | [diff] [blame] | 168 | skip_to_end = true; |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 169 | break; |
| 170 | case 't': |
| 171 | follow = false; |
| 172 | break; |
| 173 | case 'b': |
Brian Silverman | f778031 | 2014-02-16 17:26:15 -0800 | [diff] [blame] | 174 | skip_to_end = false; |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 175 | break; |
| 176 | case 'e': |
Brian Silverman | f778031 | 2014-02-16 17:26:15 -0800 | [diff] [blame] | 177 | skip_to_end = true; |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 178 | break; |
| 179 | case 'm': |
Daniel Petti | b6c885b | 2014-09-12 10:04:28 -0700 | [diff] [blame] | 180 | if (!::aos::util::StringToInteger(::std::string(optarg), &display_max)) { |
| 181 | fprintf(stderr, "ERROR: -m expects a number, not '%s'.\n", optarg); |
| 182 | exit(EXIT_FAILURE); |
| 183 | } |
| 184 | if (display_max <= 0) { |
| 185 | fprintf(stderr, "LogDisplayer: invalid max log number '%s'\n", |
| 186 | optarg); |
| 187 | exit(EXIT_FAILURE); |
| 188 | } |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 189 | break; |
| 190 | case 'o': |
| 191 | abort(); |
| 192 | break; |
| 193 | case 'h': |
| 194 | PrintHelpAndExit(); |
| 195 | break; |
| 196 | case '?': |
| 197 | break; |
| 198 | default: |
Brian Silverman | ab6615c | 2013-03-05 20:29:29 -0800 | [diff] [blame] | 199 | fprintf(stderr, "LogDisplayer: in a bad spot (%s: %d)\n", |
| 200 | __FILE__, __LINE__); |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 201 | abort(); |
| 202 | } |
| 203 | } |
| 204 | |
Daniel Petti | e6f33e2 | 2014-08-21 20:35:55 -0700 | [diff] [blame] | 205 | if (optind < argc) { |
| 206 | // We got a filename. |
| 207 | filename = argv[optind++]; |
| 208 | } |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 209 | if (optind < argc) { |
Daniel Petti | 88c81f4 | 2014-09-12 10:05:05 -0700 | [diff] [blame] | 210 | fputs("non-option ARGV-elements: ", stderr); |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 211 | while (optind < argc) { |
| 212 | fprintf(stderr, "%s\n", argv[optind++]); |
| 213 | } |
| 214 | } |
| 215 | |
Daniel Petti | e6f33e2 | 2014-08-21 20:35:55 -0700 | [diff] [blame] | 216 | fprintf(stderr, "displaying down to level %s from file '%s'\n", |
| 217 | ::aos::logging::log_str(filter_level), filename); |
| 218 | |
Brian Silverman | 65e569d | 2014-10-24 15:43:20 -0400 | [diff] [blame^] | 219 | int fd; |
| 220 | if (strcmp(filename, "-") == 0) { |
| 221 | fd = STDIN_FILENO; |
| 222 | } else { |
| 223 | fd = open(filename, O_RDONLY); |
| 224 | } |
Daniel Petti | e6f33e2 | 2014-08-21 20:35:55 -0700 | [diff] [blame] | 225 | |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 226 | if (fd == -1) { |
Brian Silverman | 01be000 | 2014-05-10 15:44:38 -0700 | [diff] [blame] | 227 | PLOG(FATAL, "couldn't open file '%s' for reading", filename); |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 228 | } |
Brian Silverman | ab5ba47 | 2014-04-18 15:26:14 -0700 | [diff] [blame] | 229 | ::aos::logging::linux_code::LogFileReader reader(fd); |
Brian Silverman | f778031 | 2014-02-16 17:26:15 -0800 | [diff] [blame] | 230 | |
| 231 | if (skip_to_end) { |
| 232 | fputs("skipping old logs...\n", stderr); |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 233 | } |
Brian Silverman | 88471dc | 2014-02-15 22:35:42 -0800 | [diff] [blame] | 234 | |
| 235 | const LogFileMessageHeader *msg; |
Daniel Petti | b6c885b | 2014-09-12 10:04:28 -0700 | [diff] [blame] | 236 | int displayed = 0; |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 237 | do { |
Brian Silverman | ab5ba47 | 2014-04-18 15:26:14 -0700 | [diff] [blame] | 238 | msg = reader.ReadNextMessage(follow); |
Brian Silverman | 003ba4b | 2014-02-10 16:56:18 -0800 | [diff] [blame] | 239 | if (msg == NULL) { |
| 240 | fputs("reached end of file\n", stderr); |
| 241 | return 0; |
| 242 | } |
Brian Silverman | 88471dc | 2014-02-15 22:35:42 -0800 | [diff] [blame] | 243 | |
Daniel Petti | b6c885b | 2014-09-12 10:04:28 -0700 | [diff] [blame] | 244 | if (source_pid >= 0 && msg->source != source_pid) { |
| 245 | // Message is from the wrong process. |
| 246 | continue; |
| 247 | } |
| 248 | |
Brian Silverman | 88471dc | 2014-02-15 22:35:42 -0800 | [diff] [blame] | 249 | if (msg->type == LogFileMessageHeader::MessageType::kStructType) { |
| 250 | size_t bytes = msg->message_size; |
| 251 | ::aos::MessageType *type = ::aos::MessageType::Deserialize( |
| 252 | reinterpret_cast<const char *>(msg + 1), &bytes); |
| 253 | ::aos::type_cache::Add(*type); |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 254 | continue; |
| 255 | } |
Brian Silverman | f665d69 | 2013-02-17 22:11:39 -0800 | [diff] [blame] | 256 | |
Brian Silverman | f778031 | 2014-02-16 17:26:15 -0800 | [diff] [blame] | 257 | if (skip_to_end) { |
Brian Silverman | ab5ba47 | 2014-04-18 15:26:14 -0700 | [diff] [blame] | 258 | if (reader.IsLastPage()) { |
Brian Silverman | f778031 | 2014-02-16 17:26:15 -0800 | [diff] [blame] | 259 | fputs("done skipping old logs\n", stderr); |
| 260 | skip_to_end = false; |
| 261 | } else { |
| 262 | continue; |
| 263 | } |
| 264 | } |
| 265 | |
Brian Silverman | 88471dc | 2014-02-15 22:35:42 -0800 | [diff] [blame] | 266 | if (::aos::logging::log_gt_important(filter_level, msg->level)) continue; |
| 267 | if (filter_name != NULL) { |
| 268 | if (filter_length != msg->name_size) continue; |
| 269 | if (memcmp(filter_name, |
| 270 | reinterpret_cast<const char *>(msg) + sizeof(*msg), |
| 271 | filter_length) != |
| 272 | 0) { |
| 273 | continue; |
| 274 | } |
| 275 | } |
| 276 | |
Daniel Petti | b6c885b | 2014-09-12 10:04:28 -0700 | [diff] [blame] | 277 | if (display_max && displayed++ >= display_max) { |
| 278 | fputs("Not displaying the rest of the messages.\n", stderr); |
| 279 | return 0; |
| 280 | } |
| 281 | |
Brian Silverman | a7234c6 | 2014-03-24 20:23:25 -0700 | [diff] [blame] | 282 | const char *position = |
| 283 | reinterpret_cast<const char *>(msg + 1) + msg->name_size; |
| 284 | #define BASE_ARGS \ |
| 285 | AOS_LOGGING_BASE_ARGS( \ |
| 286 | msg->name_size, reinterpret_cast<const char *>(msg + 1), msg->source, \ |
| 287 | msg->sequence, msg->level, msg->time_sec, msg->time_nsec) |
Brian Silverman | 88471dc | 2014-02-15 22:35:42 -0800 | [diff] [blame] | 288 | switch (msg->type) { |
Brian Silverman | a7234c6 | 2014-03-24 20:23:25 -0700 | [diff] [blame] | 289 | case LogFileMessageHeader::MessageType::kString: |
| 290 | fprintf(stdout, AOS_LOGGING_BASE_FORMAT "%.*s", BASE_ARGS, |
| 291 | static_cast<int>(msg->message_size), position); |
Brian Silverman | 88471dc | 2014-02-15 22:35:42 -0800 | [diff] [blame] | 292 | break; |
Brian Silverman | a7234c6 | 2014-03-24 20:23:25 -0700 | [diff] [blame] | 293 | case LogFileMessageHeader::MessageType::kStruct: { |
| 294 | uint32_t type_id; |
| 295 | memcpy(&type_id, position, sizeof(type_id)); |
| 296 | position += sizeof(type_id); |
Brian Silverman | 664db1a | 2014-03-20 17:06:29 -0700 | [diff] [blame] | 297 | |
Brian Silverman | a7234c6 | 2014-03-24 20:23:25 -0700 | [diff] [blame] | 298 | uint32_t string_length; |
| 299 | memcpy(&string_length, position, sizeof(string_length)); |
| 300 | position += sizeof(string_length); |
| 301 | |
| 302 | char buffer[2048]; |
| 303 | size_t output_length = sizeof(buffer); |
| 304 | size_t input_length = |
| 305 | msg->message_size - |
| 306 | (sizeof(type_id) + sizeof(uint32_t) + string_length); |
| 307 | if (!PrintMessage(buffer, &output_length, position + string_length, |
| 308 | &input_length, ::aos::type_cache::Get(type_id))) { |
| 309 | LOG(FATAL, "printing message (%.*s) of type %s into %zu-byte buffer " |
| 310 | "failed\n", |
| 311 | static_cast<int>(string_length), position, |
| 312 | ::aos::type_cache::Get(type_id).name.c_str(), sizeof(buffer)); |
| 313 | } |
| 314 | if (input_length > 0) { |
| 315 | LOG(WARNING, "%zu extra bytes on message of type %s\n", |
| 316 | input_length, ::aos::type_cache::Get(type_id).name.c_str()); |
| 317 | } |
| 318 | fprintf(stdout, AOS_LOGGING_BASE_FORMAT "%.*s: %.*s\n", BASE_ARGS, |
| 319 | static_cast<int>(string_length), position, |
| 320 | static_cast<int>(sizeof(buffer) - output_length), buffer); |
| 321 | } break; |
| 322 | case LogFileMessageHeader::MessageType::kMatrix: { |
| 323 | uint32_t type; |
| 324 | memcpy(&type, position, sizeof(type)); |
| 325 | position += sizeof(type); |
| 326 | |
| 327 | uint32_t string_length; |
| 328 | memcpy(&string_length, position, sizeof(string_length)); |
| 329 | position += sizeof(string_length); |
Brian Silverman | 664db1a | 2014-03-20 17:06:29 -0700 | [diff] [blame] | 330 | |
| 331 | uint16_t rows; |
| 332 | memcpy(&rows, position, sizeof(rows)); |
Brian Silverman | 664db1a | 2014-03-20 17:06:29 -0700 | [diff] [blame] | 333 | position += sizeof(rows); |
| 334 | uint16_t cols; |
| 335 | memcpy(&cols, position, sizeof(cols)); |
Brian Silverman | 664db1a | 2014-03-20 17:06:29 -0700 | [diff] [blame] | 336 | position += sizeof(cols); |
| 337 | |
Brian Silverman | a7234c6 | 2014-03-24 20:23:25 -0700 | [diff] [blame] | 338 | const size_t matrix_bytes = |
| 339 | msg->message_size - |
| 340 | (sizeof(type) + sizeof(uint32_t) + sizeof(uint16_t) + |
| 341 | sizeof(uint16_t) + string_length); |
| 342 | CHECK_EQ(matrix_bytes, ::aos::MessageType::Sizeof(type) * rows * cols); |
| 343 | char buffer[2048]; |
| 344 | size_t output_length = sizeof(buffer); |
| 345 | if (!::aos::PrintMatrix(buffer, &output_length, |
| 346 | position + string_length, type, rows, cols)) { |
| 347 | LOG(FATAL, "printing %dx%d matrix of type %" PRIu32 " failed\n", rows, |
| 348 | cols, type); |
| 349 | } |
| 350 | fprintf(stdout, AOS_LOGGING_BASE_FORMAT "%.*s: %.*s\n", BASE_ARGS, |
| 351 | static_cast<int>(string_length), position, |
| 352 | static_cast<int>(sizeof(buffer) - output_length), buffer); |
| 353 | } break; |
Brian Silverman | 88471dc | 2014-02-15 22:35:42 -0800 | [diff] [blame] | 354 | case LogFileMessageHeader::MessageType::kStructType: |
| 355 | LOG(FATAL, "shouldn't get here\n"); |
| 356 | break; |
Brian Silverman | a7234c6 | 2014-03-24 20:23:25 -0700 | [diff] [blame] | 357 | } |
| 358 | #undef BASE_ARGS |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 359 | } while (msg != NULL); |
| 360 | } |