OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 BASE_SYSLOG_LOGGING_H_ | 5 #ifndef BASE_SYSLOG_LOGGING_H_ |
6 #define BASE_SYSLOG_LOGGING_H_ | 6 #define BASE_SYSLOG_LOGGING_H_ |
7 | 7 |
8 #include <iosfwd> | |
9 | |
8 #include "base/logging.h" | 10 #include "base/logging.h" |
9 | 11 |
12 #if defined(OS_WIN) | |
grt (UTC plus 2)
2017/06/21 21:48:01
#include "build/build_config.h" for the definition
proberge
2017/06/22 14:35:47
Done.
| |
13 #include <windows.h> | |
14 #endif | |
15 | |
10 namespace logging { | 16 namespace logging { |
11 | 17 |
12 // Keep in mind that the syslog is always active regardless of the logging level | 18 // Keep in mind that the syslog is always active regardless of the logging level |
13 // and applied flags. Use only for important information that a system | 19 // and applied flags. Use only for important information that a system |
14 // administrator might need to maintain the browser installation. | 20 // administrator might need to maintain the browser installation. |
15 #define SYSLOG_STREAM(severity) \ | 21 #define SYSLOG_STREAM(severity) \ |
16 COMPACT_GOOGLE_LOG_EX_ ## severity(EventLogMessage).stream() | 22 COMPACT_GOOGLE_LOG_EX_ ## severity(EventLogMessage).stream() |
17 #define SYSLOG(severity) \ | 23 #define SYSLOG(severity) \ |
18 SYSLOG_STREAM(severity) | 24 SYSLOG_STREAM(severity) |
19 | 25 |
20 // Sets the name of the event source for logging to the Windows Event Log. | 26 #if defined(OS_WIN) |
21 // Call this function once before using the SYSLOG macro or otherwise it will | 27 // Sets the name, category and event id of the event source for logging to the |
22 // behave as a regular LOG macro. | 28 // Windows Event Log. Call this function once before using the SYSLOG macro or |
23 void BASE_EXPORT SetEventSourceName(const std::string& name); | 29 // otherwise it will behave as a regular LOG macro. |
30 void BASE_EXPORT SetEventSource(const std::string& name, | |
31 WORD category, | |
32 DWORD event_id); | |
33 #endif // defined(OS_WIN) | |
24 | 34 |
25 // Creates a formatted message on the system event log. That would be the | 35 // Creates a formatted message on the system event log. That would be the |
26 // Application Event log on Windows and the messages log file on POSIX systems. | 36 // Application Event log on Windows and the messages log file on POSIX systems. |
27 class BASE_EXPORT EventLogMessage { | 37 class BASE_EXPORT EventLogMessage { |
28 public: | 38 public: |
29 EventLogMessage(const char* file, int line, LogSeverity severity); | 39 EventLogMessage(const char* file, int line, LogSeverity severity); |
30 | 40 |
31 ~EventLogMessage(); | 41 ~EventLogMessage(); |
32 | 42 |
33 std::ostream& stream() { return log_message_.stream(); } | 43 std::ostream& stream() { return log_message_.stream(); } |
34 | 44 |
35 private: | 45 private: |
36 LogMessage log_message_; | 46 LogMessage log_message_; |
37 | 47 |
38 DISALLOW_COPY_AND_ASSIGN(EventLogMessage); | 48 DISALLOW_COPY_AND_ASSIGN(EventLogMessage); |
39 }; | 49 }; |
40 | 50 |
41 } // namespace logging | 51 } // namespace logging |
42 | 52 |
43 #endif // BASE_SYSLOG_LOGGING_H_ | 53 #endif // BASE_SYSLOG_LOGGING_H_ |
OLD | NEW |