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

Commit 1ca75129 authored by Nicolas Roulet's avatar Nicolas Roulet
Browse files

NBLog exchange author and timestamp positions in log

Bug: 36366826
Test: no change in functionality
Change-Id: I137695b57b9f2b84d6059b37972e06b115e10d1f
parent 6ea1d7e4
Loading
Loading
Loading
Loading
+17 −7
Original line number Diff line number Diff line
@@ -68,24 +68,32 @@ size_t NBLog::FormatEntry::formatStringLength() const {

NBLog::FormatEntry::iterator NBLog::FormatEntry::args() const {
    auto it = begin();
    // Second entry can be author or timestamp. Skip author if present
    if ((++it)->type == EVENT_AUTHOR) {
    // skip start fmt
    ++it;
    // skip timestamp
    ++it;
    // Skip author if present
    if (it->type == EVENT_AUTHOR) {
        ++it;
    }
    return ++it;
    return it;
}

timespec NBLog::FormatEntry::timestamp() const {
    auto it = begin();
    if ((++it)->type != EVENT_TIMESTAMP) {
    // skip start fmt
    ++it;
    }
    return it.payload<timespec>();
}

pid_t NBLog::FormatEntry::author() const {
    auto it = begin();
    if ((++it)->type == EVENT_AUTHOR) {
    // skip start fmt
    ++it;
    // skip timestamp
    ++it;
    // if there is an author entry, return it, return -1 otherwise
    if (it->type == EVENT_AUTHOR) {
        return it.payload<int>();
    }
    return -1;
@@ -96,6 +104,8 @@ NBLog::FormatEntry::iterator NBLog::FormatEntry::copyWithAuthor(
    auto it = begin();
    // copy fmt start entry
    it.copyTo(dst);
    // copy timestamp
    (++it).copyTo(dst);
    // insert author entry
    size_t authorEntrySize = NBLog::Entry::kOverhead + sizeof(author);
    uint8_t authorEntry[authorEntrySize];
+1 −1
Original line number Diff line number Diff line
@@ -59,8 +59,8 @@ enum Event {

// a formatted entry has the following structure:
//    * START_FMT entry, containing the format string
//    * author entry of the thread that generated it (optional, present in merged log)
//    * TIMESTAMP entry
//    * author entry of the thread that generated it (optional, present in merged log)
//    * format arg1
//    * format arg2
//    * ...