| 37 | } |
| 38 | |
| 39 | void RunLogDemo(int mode) |
| 40 | { |
| 41 | pmapi::Session sesh; |
| 42 | |
| 43 | for (auto&& o : clio::Options::Get().GetForwardedOptions()) { |
| 44 | std::cout << std::format("({}, {})", o.first, o.second) << std::endl; |
| 45 | } |
| 46 | |
| 47 | // basic log info w/ message |
| 48 | if (mode == 0) { |
| 49 | pmlog_info("information goes here"); |
| 50 | } |
| 51 | // basic warn w/ format message |
| 52 | else if (mode == 1) { |
| 53 | const int x = 4224; |
| 54 | pmlog_warn(std::format("warning with variable x = {}", x)); |
| 55 | } |
| 56 | // error log has trace (no message) |
| 57 | else if (mode == 2) { |
| 58 | f1(); |
| 59 | } |
| 60 | // disable info at runtime |
| 61 | else if (mode == 3) { |
| 62 | log::GlobalPolicy::Get().SetLogLevel(log::Level::Warning); |
| 63 | pmlog_info("info hidden"); |
| 64 | pmlog_warn("warn gets through"); |
| 65 | } |
| 66 | // show build release disable (info/warn) |
| 67 | else if (mode == 4) { |
| 68 | pmlog_info("info hidden in release, shows in debug"); |
| 69 | pmlog_error("error always shows"); |
| 70 | } |
| 71 | // set trace level |
| 72 | else if (mode == 5) { |
| 73 | log::GlobalPolicy::Get().SetTraceLevel(log::Level::Warning); |
| 74 | pmlog_warn("enable stack trace for warning"); |
| 75 | } |
| 76 | // error code logging hr |
| 77 | else if (mode == 6) { |
| 78 | CreateFileA("this-doesnt-exist.fake", 0, 0, nullptr, OPEN_EXISTING, 0, nullptr); |
| 79 | pmlog_error().hr(); |
| 80 | } |
| 81 | // error code logging pmon |
| 82 | else if (mode == 7) { |
| 83 | pmlog_error().code(PM_STATUS_INVALID_ADAPTER_ID); |
| 84 | } |
| 85 | // watch for variables |
| 86 | else if (mode == 8) { |
| 87 | const int x = 2, y = 10; |
| 88 | pmlog_info().pmwatch(x).pmwatch(y).pmwatch(std::pow(x, y)); |
| 89 | } |
| 90 | // loop frequency control 3 variants |
| 91 | else if (mode == 9) { |
| 92 | for (int i = 0; i < 9; i++) { |
| 93 | pmlog_warn("every 3").every(3); |
| 94 | pmlog_warn("first 2").first(2); |
| 95 | pmlog_warn("after 6").after(6); |
| 96 | } |
no test coverage detected