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 "base/logging.h" | 8 #include "base/logging.h" |
9 | 9 |
10 namespace logging { | 10 namespace logging { |
11 | 11 |
12 // Keep in mind that the syslog is always active regardless of the logging level | 12 // 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 | 13 // and applied flags. Use only for important information that a system |
14 // administrator might need to maintain the browser installation. | 14 // administrator might need to maintain the browser installation. |
15 #define SYSLOG_STREAM(severity) \ | 15 #define SYSLOG_STREAM(severity) \ |
16 COMPACT_GOOGLE_LOG_EX_ ## severity(EventLogMessage).stream() | 16 COMPACT_GOOGLE_LOG_EX_ ## severity(EventLogMessage).stream() |
17 #define SYSLOG(severity) \ | 17 #define SYSLOG(severity) \ |
18 SYSLOG_STREAM(severity) | 18 SYSLOG_STREAM(severity) |
19 | 19 |
| 20 // Sets the name of the event source for logging to the Windows Event Log. |
| 21 // Call this function once before using the SYSLOG macro or otherwise it will |
| 22 // behave as a regular LOG macro. |
| 23 void BASE_EXPORT SetEventSourceName(const std::string& name); |
| 24 |
20 // Creates a formatted message on the system event log. That would be the | 25 // Creates a formatted message on the system event log. That would be the |
21 // Application Event log on Windows and the messages log file on POSIX systems. | 26 // Application Event log on Windows and the messages log file on POSIX systems. |
22 class BASE_EXPORT EventLogMessage { | 27 class BASE_EXPORT EventLogMessage { |
23 public: | 28 public: |
24 EventLogMessage(const char* file, int line, LogSeverity severity); | 29 EventLogMessage(const char* file, int line, LogSeverity severity); |
25 | 30 |
26 ~EventLogMessage(); | 31 ~EventLogMessage(); |
27 | 32 |
28 std::ostream& stream() { return log_message_.stream(); } | 33 std::ostream& stream() { return log_message_.stream(); } |
29 | 34 |
30 private: | 35 private: |
31 LogMessage log_message_; | 36 LogMessage log_message_; |
32 | 37 |
33 DISALLOW_COPY_AND_ASSIGN(EventLogMessage); | 38 DISALLOW_COPY_AND_ASSIGN(EventLogMessage); |
34 }; | 39 }; |
35 | 40 |
36 } // namespace logging | 41 } // namespace logging |
37 | 42 |
38 #endif // BASE_SYSLOG_LOGGING_H_ | 43 #endif // BASE_SYSLOG_LOGGING_H_ |
OLD | NEW |