| 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 "chromeos/device_event_log_impl.h" | 5 #include "chromeos/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 13 matching lines...) Expand all Loading... |
| 24 | 24 |
| 25 namespace device_event_log { | 25 namespace device_event_log { |
| 26 | 26 |
| 27 namespace { | 27 namespace { |
| 28 | 28 |
| 29 const char* kLogLevelName[] = {"Error", "User", "Event", "Debug"}; | 29 const char* kLogLevelName[] = {"Error", "User", "Event", "Debug"}; |
| 30 | 30 |
| 31 const char* kLogTypeNetworkDesc = "Network"; | 31 const char* kLogTypeNetworkDesc = "Network"; |
| 32 const char* kLogTypePowerDesc = "Power"; | 32 const char* kLogTypePowerDesc = "Power"; |
| 33 const char* kLogTypeLoginDesc = "Login"; | 33 const char* kLogTypeLoginDesc = "Login"; |
| 34 const char* kLogTypeUsbDesc = "USB"; |
| 34 | 35 |
| 35 std::string GetLogTypeString(LogType type) { | 36 std::string GetLogTypeString(LogType type) { |
| 36 if (type == LOG_TYPE_NETWORK) | 37 switch (type) { |
| 37 return kLogTypeNetworkDesc; | 38 case LOG_TYPE_NETWORK: |
| 38 if (type == LOG_TYPE_POWER) | 39 return kLogTypeNetworkDesc; |
| 39 return kLogTypePowerDesc; | 40 case LOG_TYPE_POWER: |
| 40 if (type == LOG_TYPE_LOGIN) | 41 return kLogTypePowerDesc; |
| 41 return kLogTypeLoginDesc; | 42 case LOG_TYPE_LOGIN: |
| 42 NOTREACHED(); | 43 return kLogTypeLoginDesc; |
| 43 return "Unknown"; | 44 case LOG_TYPE_USB: |
| 45 return kLogTypeUsbDesc; |
| 46 default: |
| 47 NOTREACHED(); |
| 48 return "Unknown"; |
| 49 } |
| 44 } | 50 } |
| 45 | 51 |
| 46 std::string DateAndTimeWithMicroseconds(const base::Time& time) { | 52 std::string DateAndTimeWithMicroseconds(const base::Time& time) { |
| 47 base::Time::Exploded exploded; | 53 base::Time::Exploded exploded; |
| 48 time.LocalExplode(&exploded); | 54 time.LocalExplode(&exploded); |
| 49 // base::Time::Exploded does not include microseconds, but sometimes we need | 55 // base::Time::Exploded does not include microseconds, but sometimes we need |
| 50 // microseconds, so append '.' + usecs to the end of the formatted string. | 56 // microseconds, so append '.' + usecs to the end of the formatted string. |
| 51 int usecs = static_cast<int>(fmod(time.ToDoubleT() * 1000000, 1000000)); | 57 int usecs = static_cast<int>(fmod(time.ToDoubleT() * 1000000, 1000000)); |
| 52 return base::StringPrintf("%04d/%02d/%02d %02d:%02d:%02d.%06d", exploded.year, | 58 return base::StringPrintf("%04d/%02d/%02d %02d:%02d:%02d.%06d", exploded.year, |
| 53 exploded.month, exploded.day_of_month, | 59 exploded.month, exploded.day_of_month, |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 event(event), | 400 event(event), |
| 395 time(base::Time::Now()), | 401 time(base::Time::Now()), |
| 396 count(1) { | 402 count(1) { |
| 397 if (filedesc) | 403 if (filedesc) |
| 398 file = base::FilePath(std::string(filedesc)).BaseName().value(); | 404 file = base::FilePath(std::string(filedesc)).BaseName().value(); |
| 399 } | 405 } |
| 400 | 406 |
| 401 } // namespace device_event_log | 407 } // namespace device_event_log |
| 402 | 408 |
| 403 } // namespace chromeos | 409 } // namespace chromeos |
| OLD | NEW |