Skip to content

Commit 3b6163f

Browse files
committed
synchronize printouts
1 parent 21e132c commit 3b6163f

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

examples/logging_utils.hpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
#include <format>
44
#include <iostream>
55
#include <string_view>
6+
#include <syncstream>
67
#include <thread>
78

8-
static inline std::ostream& log() {
9-
return std::cout << std::this_thread::get_id() << " ";
9+
static inline auto log() {
10+
return std::osyncstream(std::cout) << std::this_thread::get_id() << " ";
1011
}
1112

12-
static inline std::ostream& log(std::string_view self) {
13-
return std::cout << std::this_thread::get_id() << " " << self << " ";
13+
static inline auto log(std::string_view self) {
14+
return log() << self << " ";
1415
}
1516

1617
static inline std::string format_name(std::string_view parent,

0 commit comments

Comments
 (0)