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

Commit 8ae038e4 authored by Glenn Kasten's avatar Glenn Kasten
Browse files

TypedLogger check for logWriterTLS == nullptr

logWriterTLS != nullptr

Bug: 37153050
Test: builds OK
Change-Id: I4f1202ee68a27c637ead2ff520b248a2cfe27508
parent 9c37337c
Loading
Loading
Loading
Loading
+13 −5
Original line number Diff line number Diff line
@@ -75,16 +75,24 @@ constexpr uint64_t hash(const char (&file)[n], uint32_t line) {
           std::min(line, 0xFFFFu);
}

// TODO Permit disabling of logging at compile-time.

// TODO A non-nullptr dummy implementation that is a nop would be faster than checking for nullptr
//      in the case when logging is enabled at compile-time and enabled at runtime, but it might be
//      slower than nullptr check when logging is enabled at compile-time and disabled at runtime.

// Write formatted entry to log
#define LOGT(fmt, ...) logWriterTLS->logFormat((fmt), \
                                               hash(__FILE__, __LINE__), \
                                               ##__VA_ARGS__) // TODO: check null pointer
#define LOGT(fmt, ...) do { NBLog::Writer *x = logWriterTLS; if (x != nullptr) \
                                x->logFormat((fmt), hash(__FILE__, __LINE__), ##__VA_ARGS__); } \
                                while (0)

// Write histogram timestamp entry
#define LOG_HIST_TS() logWriterTLS->logHistTS(hash(__FILE__, __LINE__))
#define LOG_HIST_TS() do { NBLog::Writer *x = logWriterTLS; if (x != nullptr) \
                                x->logHistTS(hash(__FILE__, __LINE__)); } while(0)

// flush all histogram
#define LOG_HIST_FLUSH() logWriterTLS->logHistFlush(hash(__FILE__, __LINE__))
#define LOG_HIST_FLUSH() do { NBLog::Writer *x = logWriterTLS; if (x != nullptr) \
                                x->logHistFlush(hash(__FILE__, __LINE__)); } while(0)

namespace android {
extern "C" {