3
3
#include < format>
4
4
#include " WmiCpu.h"
5
5
6
+ #define GLOG_NO_ABBREVIATED_SEVERITIES
7
+ #include < glog/logging.h>
8
+
6
9
namespace pwr ::cpu::wmi {
7
10
8
11
std::wstring kProcessorFrequency =
@@ -24,32 +27,23 @@ WmiCpu::WmiCpu() {
24
27
PdhAddEnglishCounterW (query_.get (), kProcessorFrequency .c_str (), 0 ,
25
28
&processor_frequency_counter_);
26
29
result != ERROR_SUCCESS) {
27
- throw std::runtime_error{
28
- std::format (" PdhAddEnglishCounter failed when adding processor frequency "
29
- " counter. Result: {}" ,
30
- result)
31
- .c_str ()};
30
+ LOG (INFO) << " PdhAddEnglishCounter failed when adding processor frequency counter. Result:"
31
+ << result << std::endl;
32
32
}
33
33
34
34
if (const auto result =
35
35
PdhAddEnglishCounterW (query_.get (), kProcessorPerformance .c_str (),
36
36
0 , &processor_performance_counter_);
37
37
result != ERROR_SUCCESS) {
38
- throw std::runtime_error{
39
- std::format (" PdhAddEnglishCounter failed when adding processor performance "
40
- " counter. Result: {}" ,
41
- result)
42
- .c_str ()};
38
+ LOG (INFO) << " PdhAddEnglishCounter failed when adding processor performance counter. Result:"
39
+ << result << std::endl;
43
40
}
44
41
45
42
if (const auto result = PdhAddEnglishCounterW (query_.get (), kProcessorIdleTime .c_str (), 0 ,
46
43
&processor_idle_time_counter_);
47
44
result != ERROR_SUCCESS) {
48
- throw std::runtime_error{
49
- std::format (" PdhAddEnglishCounter failed when adding "
50
- " processor time counter. Result: {}" ,
51
- result)
52
- .c_str ()};
45
+ LOG (INFO) << " PdhAddEnglishCounter failed when adding processor time counter. Result:"
46
+ << result << std::endl;
53
47
}
54
48
55
49
// Most counters require two sample values to display a formatted value.
0 commit comments