Use multiline attribute to check for IA2_STATE_MULTILINE.
[chromium-blink-merge.git] / components / device_event_log / device_event_log_impl.h
blobee33d653337a12dbcd17e04fa0835278f89de060
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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_DEVICE_EVENT_LOG_DEVICE_EVENT_LOG_IMPL_H_
6 #define COMPONENTS_DEVICE_EVENT_LOG_DEVICE_EVENT_LOG_IMPL_H_
8 #include <list>
9 #include <string>
11 #include "base/time/time.h"
12 #include "components/device_event_log/device_event_log.h"
14 namespace device_event_log {
16 class DeviceEventLogImpl {
17 public:
18 struct LogEntry {
19 LogEntry(const char* filedesc,
20 int file_line,
21 LogType log_type,
22 LogLevel log_level,
23 const std::string& event);
25 std::string file;
26 int file_line;
27 LogType log_type;
28 LogLevel log_level;
29 std::string event;
30 base::Time time;
31 int count;
34 explicit DeviceEventLogImpl(size_t max_entries);
35 ~DeviceEventLogImpl();
37 // Implements device_event_log::AddEntry.
38 void AddEntry(const char* file,
39 int file_line,
40 LogType type,
41 LogLevel level,
42 const std::string& event);
44 // Implements device_event_log::GetAsString.
45 std::string GetAsString(StringOrder order,
46 const std::string& format,
47 const std::string& types,
48 LogLevel max_level,
49 size_t max_events);
51 // Called from device_event_log::AddEntry if the global instance has not been
52 // created (or has already been destroyed). Logs to LOG(ERROR) or VLOG(1).
53 static void SendToVLogOrErrorLog(const char* file,
54 int file_line,
55 LogType type,
56 LogLevel log_level,
57 const std::string& event);
59 private:
60 friend class DeviceEventLogTest;
62 typedef std::list<LogEntry> LogEntryList;
64 void AddLogEntry(const LogEntry& entry);
66 // For testing
67 size_t max_entries() const { return max_entries_; }
68 void set_max_entries_for_test(size_t entries) { max_entries_ = entries; }
70 size_t max_entries_;
71 LogEntryList entries_;
73 DISALLOW_COPY_AND_ASSIGN(DeviceEventLogImpl);
76 } // namespace device_event_log
78 #endif // COMPONENTS_DEVICE_EVENT_LOG_DEVICE_EVENT_LOG_IMPL_H_