Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7301aaf2 authored by Erwin Jansen's avatar Erwin Jansen
Browse files

Add android emulator specific logging redirects.

This adds a set of macros to redirect logging to the android emulator
logging framework. This in turns allows the emulator to suppress
rootcanal logging if the bluetooth logging tag is not set.

Bug: 196228699
Test: gd/cert/run
Change-Id: I2e36173adf014f1a9cd8e8b24cdab9527e7d35d8
parent 308e3545
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -60,8 +60,24 @@ static_assert(LOG_TAG != nullptr, "LOG_TAG is null after header inclusion");
#endif /* FUZZ_TARGET */
#define LOG_ERROR(fmt, args...) ALOGE("%s:%d %s: " fmt, __FILE__, __LINE__, __func__, ##args)

#else
#elif defined (ANDROID_EMULATOR)
// Log using android emulator logging mechanism
#include "android/utils/debug.h"

#define LOGWRAPPER(fmt, args...) VERBOSE_INFO(bluetooth, "bluetooth: %s:%d - %s: " fmt, \
                                              __FILE__, __LINE__, __func__, ##args)

#define LOG_VEBOSE(...) LOGWRAPPER(__VA_ARGS__)
#define LOG_DEBUG(...)  LOGWRAPPER(__VA_ARGS__)
#define LOG_INFO(...)   LOGWRAPPER(__VA_ARGS__)
#define LOG_WARN(...)   LOGWRAPPER(__VA_ARGS__)
#define LOG_ERROR(...)  LOGWRAPPER(__VA_ARGS__)
#define LOG_ALWAYS_FATAL(fmt, args...)                                              \
  do {                                                                              \
    fprintf(stderr, "%s:%d - %s: " fmt "\n", __FILE__, __LINE__, __func__, ##args); \
    abort();                                                                        \
  } while (false)
#else
/* syslog didn't work well here since we would be redefining LOG_DEBUG. */
#include <chrono>
#include <cstdio>