Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
alexkushnir opened this issue Nov 7, 2024 · 0 comments

Comments

@alexkushnir
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant