Add google_apis_unittests, midi_unittests to GN swarming.
[chromium-blink-merge.git] / chromeos / network / network_event_log.h
blob7c2ba92efdd045986da5c15628662da645fb093f
1 // Copyright (c) 2012 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 CHROMEOS_NETWORK_NETWORK_EVENT_LOG_H_
6 #define CHROMEOS_NETWORK_NETWORK_EVENT_LOG_H_
8 #include <deque>
9 #include <string>
11 #include "base/basictypes.h"
12 #include "base/strings/stringprintf.h"
13 #include "base/time/time.h"
14 #include "chromeos/chromeos_export.h"
15 #include "components/device_event_log/device_event_log.h"
17 namespace base {
18 class Value;
21 namespace chromeos {
23 // Namespace for functions for logging network events.
24 namespace network_event_log {
26 namespace internal {
28 // Adds an entry to the event log at level specified by |log_level|.
29 // A maximum number of events are recorded after which new events replace
30 // old ones. Error events are prioritized such that error events will only be
31 // deleted if more than least half of the entries are errors (at which point
32 // the oldest error entry will be replaced). Does nothing unless Initialize()
33 // has been called. NOTE: Generally use NET_LOG instead.
34 CHROMEOS_EXPORT void AddEntry(const char* file,
35 int file_line,
36 device_event_log::LogLevel log_level,
37 const std::string& event,
38 const std::string& description);
40 } // namespace internal
42 // Helper function for displaying a value as a string.
43 CHROMEOS_EXPORT std::string ValueAsString(const base::Value& value);
45 // Errors
46 #define NET_LOG_ERROR(event, desc) \
47 NET_LOG_LEVEL(::device_event_log::LOG_LEVEL_ERROR, event, desc)
49 // Chrome initiated events, e.g. connection requests, scan requests,
50 // configuration removal (either from the UI or from ONC policy application).
51 #define NET_LOG_USER(event, desc) \
52 NET_LOG_LEVEL(::device_event_log::LOG_LEVEL_USER, event, desc)
54 // Important events, e.g. state updates
55 #define NET_LOG_EVENT(event, desc) \
56 NET_LOG_LEVEL(::device_event_log::LOG_LEVEL_EVENT, event, desc)
58 // Non-essential debugging events
59 #define NET_LOG_DEBUG(event, desc) \
60 NET_LOG_LEVEL(::device_event_log::LOG_LEVEL_DEBUG, event, desc)
62 // Macro to include file and line number info in the event log.
63 #define NET_LOG_LEVEL(log_level, event, description) \
64 ::device_event_log::AddEntryWithDescription( \
65 __FILE__, __LINE__, ::device_event_log::LOG_TYPE_NETWORK, log_level, \
66 event, description)
68 } // namespace network_event_log
70 } // namespace chromeos
72 #endif // CHROMEOS_NETWORK_NETWORK_EVENT_LOG_H_