diff --git a/tile/base/internal/logging.cc b/tile/base/internal/logging.cc index f14e07e..e04c4b7 100644 --- a/tile/base/internal/logging.cc +++ b/tile/base/internal/logging.cc @@ -389,7 +389,7 @@ LogSink::ToString(LogSeverity severity, { std::stringstream ss; char date_time[64]; - sprintf(date_time, "%4d-%02d-%02dT%02d:%02d:%02d.%06d", logmsgtime.year() + 1900, logmsgtime.month(), + sprintf(date_time, "%4d-%02d-%02dT%02d:%02d:%02d.%06d", logmsgtime.year() + 1900, logmsgtime.month() + 1, logmsgtime.day(), logmsgtime.hour(), logmsgtime.min(), logmsgtime.sec(), logmsgtime.usec()); ss << date_time; diff --git a/tile/base/logging/basic_file_sink.cc b/tile/base/logging/basic_file_sink.cc index 38d5210..6648d0b 100644 --- a/tile/base/logging/basic_file_sink.cc +++ b/tile/base/logging/basic_file_sink.cc @@ -23,6 +23,8 @@ BasicFileSink::Send(LogSeverity severity, size_t message_len) { TILE_CHECK(!filepath_.empty(), "filepath is empty"); + auto msg = ToString(severity, full_filename, base_filename, line, logmsgtime, message, message_len); + while (!msg.empty() && msg.back() != '\n') { msg.push_back('\n'); } ofs_ << std::string(message, message_len) << std::endl; }