Just like
MyLogger ("who is? ") " " I ' m ZRH " " I ' m in thread: " , std::this_thread::get_id ()); MyLogger (1"+"2u " = " " 3 ");
Multiple thread output shapes such as:
2016-04-16 10:54:54 who is? I ' M ZRH i ' m in thread:6736
2016-04-16 10:54:54 1 + 2 = 3
2016-04-16 10:54:54 who is? I ' M ZRH i ' m in thread:13528
2016-04-16 10:54:54 1 + 2 = 3
2016-04-16 10:54:54 who is? I ' M ZRH i ' m in thread:3036
2016-04-16 10:54:54 1 + 2 = 3
Use the
-Parentheses operator overloading
-C++11 Chrono, Iomanip gets and formats the output timestamp;
-C++11 Lock_guard to ensure that a log record is thread-safe;
-c++11 variadic template, so that you can do arbitrary parameter number and parameter type (of course, to ensure that the parameters can be printed, such as the << operator implementation);
-c++11 list initialization, braced-init-list, list initialization in the form of sequential print log, which is much better than recursive implementation;
C++11 is easy to implement thread-safe multi-parameter log syntax