OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef CHROMEOS_NETWORK_NETWORK_EVENT_LOG_H_ | 5 #ifndef CHROMEOS_NETWORK_NETWORK_EVENT_LOG_H_ |
6 #define CHROMEOS_NETWORK_NETWORK_EVENT_LOG_H_ | 6 #define CHROMEOS_NETWORK_NETWORK_EVENT_LOG_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/stringprintf.h" | |
12 #include "base/time.h" | 13 #include "base/time.h" |
13 #include "chromeos/chromeos_export.h" | 14 #include "chromeos/chromeos_export.h" |
14 | 15 |
15 namespace chromeos { | 16 namespace chromeos { |
16 | 17 |
17 // Namespace for functions for logging network events. | 18 // Namespace for functions for logging network events. |
18 namespace network_event_log { | 19 namespace network_event_log { |
19 | 20 |
20 // Used to determine which order to output event entries in GetAsString. | 21 // Used to determine which order to output event entries in GetAsString. |
21 enum StringOrder { | 22 enum StringOrder { |
(...skipping 16 matching lines...) Expand all Loading... | |
38 // after which new events replace old ones. Does nothing unless Initialize() | 39 // after which new events replace old ones. Does nothing unless Initialize() |
39 // has been called. | 40 // has been called. |
40 CHROMEOS_EXPORT void AddEntry(const std::string& module, | 41 CHROMEOS_EXPORT void AddEntry(const std::string& module, |
41 const std::string& event, | 42 const std::string& event, |
42 const std::string& description); | 43 const std::string& description); |
43 | 44 |
44 // Outputs the log to a formatted string. |order| determines which order to | 45 // Outputs the log to a formatted string. |order| determines which order to |
45 // output the events. If |max_events| > 0, limits how many events are output. | 46 // output the events. If |max_events| > 0, limits how many events are output. |
46 CHROMEOS_EXPORT std::string GetAsString(StringOrder order, size_t max_events); | 47 CHROMEOS_EXPORT std::string GetAsString(StringOrder order, size_t max_events); |
47 | 48 |
49 // Macros to make logging format more consistent. | |
50 #define NET_LOG(message) \ | |
51 ::chromeos::network_event_log::AddEntry( \ | |
52 std::string(__FILE__) + ":" + ::base::StringPrintf("%d",__LINE__), \ | |
pneubeck (no reviews)
2012/12/10 09:33:10
that seems rather fine-grained. maybe better:
modu
stevenjb
2012/12/10 20:46:51
Agreed (although I'd do __FUNC__:__LINE__). I expe
Greg Spencer (Chromium)
2012/12/10 23:54:03
What about if I just combine all of them for the "
| |
53 std::string(__func__), \ | |
54 message) | |
55 | |
56 #define NET_LOG_WARNING(message) \ | |
57 NET_LOG(std::string("WARNING:") + message) | |
58 #define NET_LOG_ERROR(message) \ | |
59 NET_LOG(std::string("ERROR:") + message) | |
60 | |
48 } // namespace network_event_log | 61 } // namespace network_event_log |
49 | 62 |
50 } // namespace chromeos | 63 } // namespace chromeos |
51 | 64 |
52 #endif // CHROMEOS_NETWORK_NETWORK_EVENT_LOG_H_ | 65 #endif // CHROMEOS_NETWORK_NETWORK_EVENT_LOG_H_ |
OLD | NEW |