Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3132)

Unified Diff: base/syslog_logging.cc

Issue 2530163002: Make the name of the event source for SYSLOG configurable. (Closed)
Patch Set: Fix BUILD.gn Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
« no previous file with comments | « base/syslog_logging.h ('k') | chrome/common/BUILD.gn » ('j') | chrome/common/logging_chrome.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698