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

Commit 6e312d29 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Logging: Rename buf and now to avoid collisions"

parents 02a9f932 9401a23d
Loading
Loading
Loading
Loading
+11 −10
Original line number Diff line number Diff line
@@ -50,14 +50,15 @@

#define LOGWRAPPER(fmt, args...)                                                                                    \
  do {                                                                                                              \
    auto now = std::chrono::system_clock::now();                                                                      \
    auto now_ms = std::chrono::time_point_cast<std::chrono::milliseconds>(now);                                       \
    auto now_t = std::chrono::system_clock::to_time_t(now);                                                           \
    auto _now = std::chrono::system_clock::now();                                                                   \
    auto _now_ms = std::chrono::time_point_cast<std::chrono::milliseconds>(_now);                                   \
    auto _now_t = std::chrono::system_clock::to_time_t(_now);                                                       \
    /* YYYY-MM-DD_HH:MM:SS.sss is 23 byte long, plus 1 for null terminator */                                       \
    char buf[24];                                                                                                     \
    auto l = std::strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", std::localtime(&now_t));                            \
    snprintf(buf + l, sizeof(buf) - l, ".%03u", static_cast<unsigned int>(now_ms.time_since_epoch().count() % 1000)); \
    fprintf(stderr, "%s %s - %s:%d - %s: " fmt "\n", buf, LOG_TAG, __FILE__, __LINE__, __func__, ##args);             \
    char _buf[24];                                                                                                  \
    auto l = std::strftime(_buf, sizeof(_buf), "%Y-%m-%d %H:%M:%S", std::localtime(&_now_t));                       \
    snprintf(                                                                                                       \
        _buf + l, sizeof(_buf) - l, ".%03u", static_cast<unsigned int>(_now_ms.time_since_epoch().count() % 1000)); \
    fprintf(stderr, "%s %s - %s:%d - %s: " fmt "\n", _buf, LOG_TAG, __FILE__, __LINE__, __func__, ##args);          \
  } while (false)

#ifdef FUZZ_TARGET