Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1732)

Side by Side Diff: components/device_event_log/device_event_log_impl.cc

Issue 947663002: Log device/hid messages to chrome://device-log. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clarified destructor behavior, cleaned up OS X error logging. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_impl.h" 5 #include "components/device_event_log/device_event_log_impl.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <list> 8 #include <list>
9 #include <set> 9 #include <set>
10 10
(...skipping 12 matching lines...) Expand all
23 namespace device_event_log { 23 namespace device_event_log {
24 24
25 namespace { 25 namespace {
26 26
27 const char* kLogLevelName[] = {"Error", "User", "Event", "Debug"}; 27 const char* kLogLevelName[] = {"Error", "User", "Event", "Debug"};
28 28
29 const char* kLogTypeNetworkDesc = "Network"; 29 const char* kLogTypeNetworkDesc = "Network";
30 const char* kLogTypePowerDesc = "Power"; 30 const char* kLogTypePowerDesc = "Power";
31 const char* kLogTypeLoginDesc = "Login"; 31 const char* kLogTypeLoginDesc = "Login";
32 const char* kLogTypeUsbDesc = "USB"; 32 const char* kLogTypeUsbDesc = "USB";
33 const char* kLogTypeHidDesc = "HID";
33 34
34 std::string GetLogTypeString(LogType type) { 35 std::string GetLogTypeString(LogType type) {
35 switch (type) { 36 switch (type) {
36 case LOG_TYPE_NETWORK: 37 case LOG_TYPE_NETWORK:
37 return kLogTypeNetworkDesc; 38 return kLogTypeNetworkDesc;
38 case LOG_TYPE_POWER: 39 case LOG_TYPE_POWER:
39 return kLogTypePowerDesc; 40 return kLogTypePowerDesc;
40 case LOG_TYPE_LOGIN: 41 case LOG_TYPE_LOGIN:
41 return kLogTypeLoginDesc; 42 return kLogTypeLoginDesc;
42 case LOG_TYPE_USB: 43 case LOG_TYPE_USB:
43 return kLogTypeUsbDesc; 44 return kLogTypeUsbDesc;
45 case LOG_TYPE_HID:
46 return kLogTypeHidDesc;
44 default: 47 default:
45 NOTREACHED(); 48 NOTREACHED();
46 return "Unknown"; 49 return "Unknown";
47 } 50 }
48 } 51 }
49 52
50 std::string DateAndTimeWithMicroseconds(const base::Time& time) { 53 std::string DateAndTimeWithMicroseconds(const base::Time& time) {
51 base::Time::Exploded exploded; 54 base::Time::Exploded exploded;
52 time.LocalExplode(&exploded); 55 time.LocalExplode(&exploded);
53 // base::Time::Exploded does not include microseconds, but sometimes we need 56 // base::Time::Exploded does not include microseconds, but sometimes we need
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 if (filedesc) { 401 if (filedesc) {
399 file = filedesc; 402 file = filedesc;
400 size_t last_slash_pos = file.find_last_of("\\/"); 403 size_t last_slash_pos = file.find_last_of("\\/");
401 if (last_slash_pos != std::string::npos) { 404 if (last_slash_pos != std::string::npos) {
402 file.erase(0, last_slash_pos + 1); 405 file.erase(0, last_slash_pos + 1);
403 } 406 }
404 } 407 }
405 } 408 }
406 409
407 } // namespace device_event_log 410 } // namespace device_event_log
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698