Index: components/device_event_log/device_event_log.h |
diff --git a/components/device_event_log/device_event_log.h b/components/device_event_log/device_event_log.h |
index 7a0948606644cc7280d1f6bf50bdbfefc6cbbb4e..d25bd3e519bd5393fe78d12d334245aacd4f3c2b 100644 |
--- a/components/device_event_log/device_event_log.h |
+++ b/components/device_event_log/device_event_log.h |
@@ -9,6 +9,7 @@ |
#include <sstream> |
#include "base/basictypes.h" |
+#include "base/logging.h" |
#include "base/timer/elapsed_timer.h" |
#include "components/device_event_log/device_event_log_export.h" |
@@ -34,12 +35,22 @@ |
#define USB_LOG(level) \ |
DEVICE_LOG(::device_event_log::LOG_TYPE_USB, \ |
::device_event_log::LOG_LEVEL_##level) |
+#define HID_LOG(level) \ |
+ DEVICE_LOG(::device_event_log::LOG_TYPE_HID, \ |
+ ::device_event_log::LOG_LEVEL_##level) |
+#define HID_PLOG(level) \ |
+ DEVICE_PLOG(::device_event_log::LOG_TYPE_HID, \ |
+ ::device_event_log::LOG_LEVEL_##level) |
-// Generally prefer the above macros unless |type| or |level| is not constant. |
+// Generally prefer the above macros unless |type| or |level| is not constant. |
#define DEVICE_LOG(type, level) \ |
::device_event_log::internal::DeviceEventLogInstance(__FILE__, __LINE__, \ |
type, level).stream() |
+#define DEVICE_PLOG(type, level) \ |
+ ::device_event_log::internal::DeviceEventSystemErrorLogInstance( \ |
+ __FILE__, __LINE__, type, level, ::logging::GetLastSystemErrorCode()) \ |
+ .stream() |
// Declare {Type_LOG_IF_SLOW() at the top of a method to log slow methods |
// where "slow" is defined by kSlowMethodThresholdMs in the .cc file. |
@@ -66,6 +77,8 @@ enum LogType { |
LOG_TYPE_LOGIN, |
// USB device related events (i.e. device/usb). |
LOG_TYPE_USB, |
+ // Human-interface device related events (i.e. device/hid). |
+ LOG_TYPE_HID, |
// Used internally |
LOG_TYPE_UNKNOWN |
}; |
@@ -156,6 +169,29 @@ class DEVICE_EVENT_LOG_EXPORT DeviceEventLogInstance { |
DISALLOW_COPY_AND_ASSIGN(DeviceEventLogInstance); |
}; |
+// Implementation class for DEVICE_PLOG macros. Provides a stream for createing |
stevenjb
2015/02/23 21:45:29
creating
Reilly Grant (use Gerrit)
2015/02/23 22:40:38
Done.
|
+// a log string and adds the event, including system error code, using |
+// device_event_log::AddEntry on destruction. |
+class DEVICE_EVENT_LOG_EXPORT DeviceEventSystemErrorLogInstance { |
+ public: |
+ DeviceEventSystemErrorLogInstance(const char* file, |
+ int line, |
+ device_event_log::LogType type, |
+ device_event_log::LogLevel level, |
+ logging::SystemErrorCode err); |
+ |
+ // Appends the error message before destructing the encapsulated class. |
+ ~DeviceEventSystemErrorLogInstance(); |
+ |
+ std::ostream& stream() { return log_instance_.stream(); } |
+ |
+ private: |
+ logging::SystemErrorCode err_; |
+ DeviceEventLogInstance log_instance_; |
stevenjb
2015/02/23 21:45:29
This is subtle; I missed the comment above the des
Reilly Grant (use Gerrit)
2015/02/23 22:40:38
Done.
|
+ |
+ DISALLOW_COPY_AND_ASSIGN(DeviceEventSystemErrorLogInstance); |
+}; |
+ |
// Implementation class for SCOPED_LOG_IF_SLOW macros. Tests the elapsed time on |
// destruction and adds a Debug or Error log entry if it exceeds the |
// corresponding expected maximum elapsed time. |