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

Unified Diff: base/syslog_logging.cc

Issue 2946983002: Move eventlog_provider from //base/win to //chrome/common/win (Closed)
Patch Set: Address review comments on #3 Created 3 years, 6 months 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 087b4fd4543195d14bc38b040e58ec5314436f39..0e350aaede119535e45358c0c74f5f514df093a2 100644
--- a/base/syslog_logging.cc
+++ b/base/syslog_logging.cc
@@ -2,20 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/debug/stack_trace.h"
#include "base/syslog_logging.h"
+#include "base/debug/stack_trace.h"
grt (UTC plus 2) 2017/06/21 21:48:01 nit: move this into the OS_WIN block below?
proberge 2017/06/22 14:35:47 Done.
+
#if defined(OS_WIN)
#include "base/bind.h"
#include "base/callback_helpers.h"
-#include "base/win/eventlog_messages.h"
-
-#include <windows.h>
#elif defined(OS_LINUX)
#include <syslog.h>
#endif
-#include <cstring>
#include <ostream>
#include <string>
@@ -24,13 +21,20 @@ namespace logging {
#if defined(OS_WIN)
namespace {
+
std::string* g_event_source_name = nullptr;
-}
+WORD g_category = 0;
+DWORD g_event_id = 0;
-void SetEventSourceName(const std::string& name) {
+} // namespace
+
+void SetEventSource(const std::string& name, WORD category, DWORD event_id) {
DCHECK_EQ(nullptr, g_event_source_name);
g_event_source_name = new std::string(name);
+ g_category = category;
+ g_event_id = event_id;
}
+
#endif // defined(OS_WIN)
EventLogMessage::EventLogMessage(const char* file,
@@ -48,8 +52,8 @@ EventLogMessage::~EventLogMessage() {
return;
HANDLE event_log_handle =
- RegisterEventSourceA(NULL, g_event_source_name->c_str());
- if (event_log_handle == NULL) {
+ RegisterEventSourceA(nullptr, g_event_source_name->c_str());
+ if (event_log_handle == nullptr) {
stream() << " !!NOT ADDED TO EVENTLOG!!";
return;
}
@@ -75,8 +79,8 @@ EventLogMessage::~EventLogMessage() {
break;
}
LPCSTR strings[1] = {message.data()};
- if (!ReportEventA(event_log_handle, log_type, BROWSER_CATEGORY,
- MSG_LOG_MESSAGE, NULL, 1, 0, strings, NULL)) {
+ if (!ReportEventA(event_log_handle, log_type, g_category, g_event_id, nullptr,
+ 1, 0, strings, nullptr)) {
stream() << " !!NOT ADDED TO EVENTLOG!!";
}
#elif defined(OS_LINUX)
« base/syslog_logging.h ('K') | « base/syslog_logging.h ('k') | base/win/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698