Skip to content
This repository was archived by the owner on Jun 30, 2025. It is now read-only.
This repository was archived by the owner on Jun 30, 2025. It is now read-only.

Log line format string in the log header displays threadid even if it wasn't selected to display in custom formatter #1139

@alexkushnir

Description

@alexkushnir

Use the following snippet:

void custom_formatter(std::ostream& s, const google::LogMessage& m, void* data)
{
    s << google::GetLogSeverityName(m.severity())[0]
        << "["
        << std::setw(2) << m.time().hour() << ':'
        << std::setw(2) << m.time().min()  << ':'
        << std::setw(2) << m.time().sec() << "."
        << ' '
        << std::setfill(' ') << std::setw(5)
        << ' '
        << m.basename() << ':' << m.line() << "]";
}
int main(int argc, char** argv)
{
    google::InitGoogleLogging(argv[0]); 
    google::InstallPrefixFormatter(&custom_formatter);
    auto num_cookies = 15;
    LOG(INFO) << "Found " << num_cookies << " cookies"; 
    return 0;
}

Gives the following output:

Log file created at: 2024/11/07 16:12:06
Running on machine: AAAAAAAAAAA
Running duration (h:mm:ss): 0:00:00
Log line format: [IWEF]yyyymmdd hh:mm:ss.uuuuuu threadid file:line] msg
I[16:12:06.      glog_functions.cpp:72] Found 15 cookies

I would expect the threadid would not appear in the log line format

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions