Skip to content

Commit

Permalink
Added log_prefix_include_pid flag that adds PID into log prefix (yuga…
Browse files Browse the repository at this point in the history
  • Loading branch information
ttyusupov authored Mar 22, 2021
1 parent ebbe344 commit f690143
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/logging.cc
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ GLOG_DEFINE_string(alsologtoemail, "",
"in addition to logfiles");
GLOG_DEFINE_bool(log_prefix, true,
"Prepend the log prefix to the start of each log line");
GLOG_DEFINE_bool(log_prefix_include_pid, false,
"Include PID into the log prefix");
GLOG_DEFINE_int32(minloglevel, 0, "Messages logged at a lower level than this don't "
"actually get logged anywhere");
GLOG_DEFINE_int32(logbuflevel, 0,
Expand Down Expand Up @@ -1294,8 +1296,11 @@ void LogMessage::Init(const char* file,
<< setw(2) << data_->tm_time_.tm_sec << "."
<< setw(6) << usecs
<< ' '
<< setfill(' ') << setw(5)
<< static_cast<unsigned int>(GetTID()) << setfill('0')
<< setfill(' ') << setw(5);
if (FLAGS_log_prefix_include_pid) {
stream() << static_cast<unsigned int>(getpid()) << setfill('0') << ' ';
}
stream() << static_cast<unsigned int>(GetTID()) << setfill('0')
<< ' '
<< data_->basename_ << ':' << data_->line_ << "] ";
}
Expand Down

0 comments on commit f690143

Please sign in to comment.