OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/device_event_log/device_event_log.h" | 5 #include "components/device_event_log/device_event_log.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "components/device_event_log/device_event_log_impl.h" | 10 #include "components/device_event_log/device_event_log_impl.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 int line, | 77 int line, |
78 device_event_log::LogType type, | 78 device_event_log::LogType type, |
79 device_event_log::LogLevel level) | 79 device_event_log::LogLevel level) |
80 : file_(file), line_(line), type_(type), level_(level) { | 80 : file_(file), line_(line), type_(type), level_(level) { |
81 } | 81 } |
82 | 82 |
83 DeviceEventLogInstance::~DeviceEventLogInstance() { | 83 DeviceEventLogInstance::~DeviceEventLogInstance() { |
84 device_event_log::AddEntry(file_, line_, type_, level_, stream_.str()); | 84 device_event_log::AddEntry(file_, line_, type_, level_, stream_.str()); |
85 } | 85 } |
86 | 86 |
| 87 DeviceEventSystemErrorLogInstance::DeviceEventSystemErrorLogInstance( |
| 88 const char* file, |
| 89 int line, |
| 90 device_event_log::LogType type, |
| 91 device_event_log::LogLevel level, |
| 92 logging::SystemErrorCode err) |
| 93 : err_(err), log_instance_(file, line, type, level) { |
| 94 } |
| 95 |
| 96 DeviceEventSystemErrorLogInstance::~DeviceEventSystemErrorLogInstance() { |
| 97 stream() << ": " << ::logging::SystemErrorCodeToString(err_); |
| 98 } |
| 99 |
87 ScopedDeviceLogIfSlow::ScopedDeviceLogIfSlow(LogType type, | 100 ScopedDeviceLogIfSlow::ScopedDeviceLogIfSlow(LogType type, |
88 const char* file, | 101 const char* file, |
89 const std::string& name) | 102 const std::string& name) |
90 : file_(file), type_(type), name_(name) { | 103 : file_(file), type_(type), name_(name) { |
91 } | 104 } |
92 | 105 |
93 ScopedDeviceLogIfSlow::~ScopedDeviceLogIfSlow() { | 106 ScopedDeviceLogIfSlow::~ScopedDeviceLogIfSlow() { |
94 if (timer_.Elapsed().InMilliseconds() >= kSlowMethodThresholdMs) { | 107 if (timer_.Elapsed().InMilliseconds() >= kSlowMethodThresholdMs) { |
95 LogLevel level(LOG_LEVEL_DEBUG); | 108 LogLevel level(LOG_LEVEL_DEBUG); |
96 if (timer_.Elapsed().InMilliseconds() >= kVerySlowMethodThresholdMs) | 109 if (timer_.Elapsed().InMilliseconds() >= kVerySlowMethodThresholdMs) |
97 level = LOG_LEVEL_ERROR; | 110 level = LOG_LEVEL_ERROR; |
98 DEVICE_LOG(type_, level) << "@@@ Slow method: " << file_ << ":" << name_ | 111 DEVICE_LOG(type_, level) << "@@@ Slow method: " << file_ << ":" << name_ |
99 << ": " << timer_.Elapsed().InMilliseconds() | 112 << ": " << timer_.Elapsed().InMilliseconds() |
100 << "ms"; | 113 << "ms"; |
101 } | 114 } |
102 } | 115 } |
103 | 116 |
104 } // namespace internal | 117 } // namespace internal |
105 | 118 |
106 } // namespace device_event_log | 119 } // namespace device_event_log |
OLD | NEW |