Index: base/syslog_logging.cc |
diff --git a/base/syslog_logging.cc b/base/syslog_logging.cc |
index 1cd545910a967a6f52f5a138136bceb8be6782fd..0e8308d7b579ab743d492232e4309edb7ea9602d 100644 |
--- a/base/syslog_logging.cc |
+++ b/base/syslog_logging.cc |
@@ -19,6 +19,18 @@ |
namespace logging { |
+#if defined(OS_WIN) |
+ |
+namespace { |
+std::string* g_event_source_name = nullptr; |
+} |
+ |
+void SetEventSourceName(const std::string& name) { |
+ DCHECK(g_event_source_name == nullptr); |
grt (UTC plus 2)
2016/11/28 12:49:52
nit: DCHECK_EQ(g_event_source_name, nullptr);
pastarmovj
2016/11/28 15:53:17
Done.
|
+ g_event_source_name = new std::string(name); |
+} |
+#endif // defined(OS_WIN) |
+ |
EventLogMessage::EventLogMessage(const char* file, |
int line, |
LogSeverity severity) |
@@ -27,8 +39,16 @@ EventLogMessage::EventLogMessage(const char* file, |
EventLogMessage::~EventLogMessage() { |
#if defined(OS_WIN) |
- const char kEventSource[] = "chrome"; |
- HANDLE event_log_handle = RegisterEventSourceA(NULL, kEventSource); |
+ // If g_event_source_name is nullptr (which it is per default) SYSLOG will |
+ // degrade gracefully to regular LOG with an extra error suffix. If you see |
+ // this happening most probably you are using SYSLOG before you called |
+ // SetEventSourceName. |
+ if (g_event_source_name == nullptr) { |
+ stream() << " !!EVENTLOG SOURCE NAME NOT SET!!"; |
+ return; |
+ } |
+ HANDLE event_log_handle = |
+ RegisterEventSourceA(NULL, g_event_source_name->c_str()); |
if (event_log_handle == NULL) { |
stream() << " !!NOT ADDED TO EVENTLOG!!"; |
return; |