blob: ff0167a10db9ef6b731741e9761673763d731cb7 [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"
Brian Silvermanfd5e2a32014-02-22 20:02:39 -080010#include "aos/common/die.h"
Brian Silvermand6974f42014-02-14 13:39:21 -080011
12namespace aos {
13namespace logging {
14
Brian Silvermanfd5e2a32014-02-22 20:02:39 -080015// Logs the contents of a structure (or Queue message) and a constant string.
16// structure must be an instance of one of the generated queue types.
Brian Silvermand6974f42014-02-14 13:39:21 -080017#define LOG_STRUCT(level, message, structure) \
18 do { \
19 static const ::std::string kAosLoggingMessage( \
20 LOG_SOURCENAME ": " STRINGIFY(__LINE__) ": " message); \
21 ::aos::logging::DoLogStruct(level, kAosLoggingMessage, structure); \
22 /* so that GCC knows that it won't return */ \
23 if (level == FATAL) { \
Brian Silvermanfd5e2a32014-02-22 20:02:39 -080024 ::aos::Die("DoLogStruct(FATAL) fell through!!!!!\n"); \
Brian Silvermand6974f42014-02-14 13:39:21 -080025 } \
26 } while (false)
Brian Silvermand6974f42014-02-14 13:39:21 -080027
28template <class T>
29void DoLogStruct(log_level level, const ::std::string &message,
30 const T &structure);
31
32} // namespace logging
33} // namespace aos
34
35#include "aos/common/logging/queue_logging-tmpl.h"
36
37#endif // AOS_COMMON_LOGGING_QUEUE_LOGGING_H_