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

Unified Diff: base/syslog_logging.cc

Issue 2530163002: Make the name of the event source for SYSLOG configurable. (Closed)
Patch Set: Change to per-channel naming. 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..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;

Powered by Google App Engine
This is Rietveld 408576698