Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This refactoring addresses fundamental issues with Unicode and cross-platform compatibility in our logging sinks. The previous implementation, which relied on C++ iostreams, was not robust enough for a library like ONNX Runtime that must operate correctly in diverse host environments. For example, it does not work at all in python on Windows. When you run onnx_backend_test_series.py on Windows, you will see logs like:

It looks weird that every char has an extra space after that. However, it is not a display issue. It is a character encoding issue.
Background
Several alternative approaches were considered and rejected due to significant drawbacks:
The std::wcout and _setmode Trap: A common method for printing Unicode on Windows is using std::wcout after switching the stream's mode to a Unicode format (e.g., _O_U16TEXT) with _setmode. This approach is unsuitable for a library for two critical reasons:
Per-Call Mode Switching and Race Conditions: One might consider switching the stream's mode to Unicode before each write and switching it back immediately after. While this avoids a permanent global change, it introduces a significant thread-safety issue. If two threads—one from the host application and one from ONNX Runtime—attempt to write to stdout concurrently, the output will likely be garbled anyway. More importantly, we cannot assume that no two threads will use the same stream concurrently, and making such an assumption would lead to race conditions between the mode-switching calls themselves. A library must not impose such threading constraints on its host.
The Limitations of Multibyte APIs (ANSI Code Pages): Using the multibyte -A versions of the Windows API is also not a viable solution for modern applications.
Main changes:
Modernized FileSink:
The constructor now uses the modern std::filesystem::path for file paths and std::mutex for thread safety.
C-style FILE* streams were used instead of C++ iostreams because the C functions have less layers. For example, we do not need to consider the impact of
imbue.