Significantly improve logging speed.
GitOrigin-RevId: 5ac20138653e0d43b729406296f6dc1c2d790dd7
This commit is contained in:
parent
fbca30b2b4
commit
4a0eeb5792
@ -70,7 +70,16 @@ Logger::Logger(LogInterface &log, const LogOptions &options, int log_level, Slic
|
||||
sb_ << thread_id << ']';
|
||||
|
||||
// timestamp
|
||||
sb_ << '[' << StringBuilder::FixedDouble(Clocks::system(), 9) << ']';
|
||||
auto time = Clocks::system();
|
||||
auto unix_time = static_cast<int32>(time);
|
||||
auto nanoseconds = static_cast<int32>((time - unix_time) * 1e9);
|
||||
sb_ << '[' << unix_time << '.';
|
||||
auto limit = 100000000;
|
||||
while (nanoseconds < limit && limit > 1) {
|
||||
sb_ << '0';
|
||||
limit /= 10;
|
||||
}
|
||||
sb_ << nanoseconds << ']';
|
||||
|
||||
// file : line
|
||||
if (!file_name.empty()) {
|
||||
@ -79,7 +88,7 @@ Logger::Logger(LogInterface &log, const LogOptions &options, int log_level, Slic
|
||||
last_slash_--;
|
||||
}
|
||||
file_name = file_name.substr(last_slash_ + 1);
|
||||
sb_ << "[" << file_name << ':' << line_num << ']';
|
||||
sb_ << '[' << file_name << ':' << line_num << ']';
|
||||
}
|
||||
|
||||
// context from tag_
|
||||
|
Loading…
Reference in New Issue
Block a user