You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

main.cpp 1.2 kB

2 years ago
1234567891011121314151617181920212223242526272829303132333435
  1. #include <string>
  2. #include <thread>
  3. #include "xlog.h"
  4. int main()
  5. {
  6. // print log test, you can transfer any param to do format
  7. int param = 1;
  8. std::thread thd1([&param](){
  9. for (int i = 0; i < 100000; i++) {
  10. _T("this is trace log record, param: {}", ++param); // int type param is ok
  11. _D("this is debug log record, param: {}", ++param);
  12. _I("this is info log record, param: {}", ++param);
  13. _W("this is warn log record, param: {}", double(++param)); // double type param is ok
  14. _E("this is error log record, param: {}", std::to_string(++param)); // string type param is ok
  15. }
  16. });
  17. std::thread thd2([&param](){
  18. for (int i = 0; i < 100000; i++) {
  19. _T("this is trace log record, param: {}", ++param); // int type param is ok
  20. _D("this is debug log record, param: {}", ++param);
  21. _I("this is info log record, param: {}", ++param);
  22. _W("this is warn log record, param: {}", double(++param)); // double type param is ok
  23. _E("this is error log record, param: {}", std::to_string(++param)); // string type param is ok
  24. }
  25. });
  26. thd1.join();
  27. thd2.join();
  28. return 0;
  29. }