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

Description
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