blob: df343dfe675f7f0c4a396c4382d3833c3697c133 [file] [log] [blame]
Brian Silvermand6974f42014-02-14 13:39:21 -08001#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"
10
11namespace aos {
12namespace logging {
13
Brian Silverman88471dc2014-02-15 22:35:42 -080014#if 1
Brian Silvermand6974f42014-02-14 13:39:21 -080015#define LOG_STRUCT(level, message, structure) \
16 do { \
17 static const ::std::string kAosLoggingMessage( \
18 LOG_SOURCENAME ": " STRINGIFY(__LINE__) ": " message); \
19 ::aos::logging::DoLogStruct(level, kAosLoggingMessage, structure); \
20 /* so that GCC knows that it won't return */ \
21 if (level == FATAL) { \
22 fprintf(stderr, "DoLogStruct(FATAL) fell through!!!!!\n"); \
23 printf("see stderr\n"); \
24 abort(); \
25 } \
26 } while (false)
Brian Silverman88471dc2014-02-15 22:35:42 -080027#else
28#define LOG_STRUCT(level, message, structure)
29#endif
Brian Silvermand6974f42014-02-14 13:39:21 -080030
31template <class T>
32void DoLogStruct(log_level level, const ::std::string &message,
33 const T &structure);
34
35} // namespace logging
36} // namespace aos
37
38#include "aos/common/logging/queue_logging-tmpl.h"
39
40#endif // AOS_COMMON_LOGGING_QUEUE_LOGGING_H_