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

Commit 397ddfb4 authored by Nicolas Roulet's avatar Nicolas Roulet Committed by Android (Google) Code Review
Browse files

Merge "NBLog exchange author and timestamp positions in log"

parents eecac2ca 1ca75129
Loading
Loading
Loading
Loading
+17 −7
Original line number Original line Diff line number Diff line
@@ -68,24 +68,32 @@ size_t NBLog::FormatEntry::formatStringLength() const {


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


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


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


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