Skip to content

Commit 7f34d3b

Browse files
committed
add wostream overloads for Timestamp operator<<
1 parent dad1617 commit 7f34d3b

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

include/onnxruntime/core/common/logging/logging.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,13 @@ class Timestamp {
6969
return time_stamp.WriteToStream(os);
7070
}
7171

72+
friend std::wostream& operator<<(std::wostream& os, const Timestamp& time_stamp) {
73+
return time_stamp.WriteToWStream(os);
74+
}
75+
7276
private:
7377
std::ostream& WriteToStream(std::ostream& os) const;
78+
std::wostream& WriteToWStream(std::wostream& os) const;
7479

7580
TimePoint time_point_{};
7681
};

onnxruntime/core/common/logging/logging.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ std::ostream& Timestamp::WriteToStream(std::ostream& os) const {
7171
return timestamp_stream_insertion_op_ns::operator<<(os, time_point_);
7272
}
7373

74+
std::wostream& Timestamp::WriteToWStream(std::wostream& os) const {
75+
return timestamp_stream_insertion_op_ns::operator<<(os, time_point_);
76+
}
77+
7478
const char* Category::onnxruntime = "onnxruntime";
7579
const char* Category::System = "System";
7680

onnxruntime/core/common/logging/sinks/ostream_sink.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,6 @@ void OStreamSink::SendImpl(const Timestamp& timestamp, const std::string& logger
6262
}
6363
#else
6464
void WOStreamSink::SendImpl(const Timestamp& timestamp, const std::string& logger_id, const Capture& message) {
65-
// operator for formatting of timestamp in ISO8601 format including microseconds
66-
using date::operator<<;
67-
6865
// Two options as there may be multiple calls attempting to write to the same sink at once:
6966
// 1) Use mutex to synchronize access to the stream.
7067
// 2) Create the message in an ostringstream and output in one call.

onnxruntime/core/session/inference_session.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ inline const wchar_t* GetDateFormatString<wchar_t>() {
113113
return L"%Y-%m-%d_%H-%M-%S";
114114
}
115115
#endif
116-
// TODO: use LoggingManager::GetTimestamp and date::operator<<
116+
// TODO: use LoggingManager::GetTimestamp and operator<<
117117
// (see ostream_sink.cc for an example)
118118
// to simplify this and match the log file timestamp format.
119119
template <typename T>

0 commit comments

Comments
 (0)