 Chromium Code Reviews
 Chromium Code Reviews Issue 2530163002:
  Make the name of the event source for SYSLOG configurable.  (Closed)
    
  
    Issue 2530163002:
  Make the name of the event source for SYSLOG configurable.  (Closed) 
  | Index: base/syslog_logging.cc | 
| diff --git a/base/syslog_logging.cc b/base/syslog_logging.cc | 
| index 1cd545910a967a6f52f5a138136bceb8be6782fd..815d5dbf4665964d8f0ae16c0ba7f7e54f2b1b1f 100644 | 
| --- a/base/syslog_logging.cc | 
| +++ b/base/syslog_logging.cc | 
| @@ -19,6 +19,17 @@ | 
| namespace logging { | 
| +#if defined(OS_WIN) | 
| + | 
| +namespace { | 
| +std::string g_event_source_name; | 
| 
grt (UTC plus 2)
2016/11/25 15:25:34
non-POD globals are banned (https://google.github.
 
pastarmovj
2016/11/28 12:23:03
Done.
 | 
| +} | 
| + | 
| +void SetEventSourceName(const std::string& name) { | 
| + g_event_source_name = name; | 
| +} | 
| +#endif // defined(OS_WIN) | 
| + | 
| EventLogMessage::EventLogMessage(const char* file, | 
| int line, | 
| LogSeverity severity) | 
| @@ -27,8 +38,12 @@ 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 empty (which it is per default) this call will | 
| + // fail and 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. | 
| + HANDLE event_log_handle = | 
| + RegisterEventSourceA(NULL, g_event_source_name.c_str()); | 
| if (event_log_handle == NULL) { | 
| stream() << " !!NOT ADDED TO EVENTLOG!!"; | 
| return; |