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

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 #5 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
« no previous file with comments | « base/syslog_logging.h ('k') | base/win/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/syslog_logging.cc
diff --git a/base/syslog_logging.cc b/base/syslog_logging.cc
index 087b4fd4543195d14bc38b040e58ec5314436f39..3818a146930fbf3e04cdc817159c82ce547672c5 100644
--- a/base/syslog_logging.cc
+++ b/base/syslog_logging.cc
@@ -2,20 +2,16 @@
// 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"
#if defined(OS_WIN)
#include "base/bind.h"
#include "base/callback_helpers.h"
-#include "base/win/eventlog_messages.h"
-
-#include <windows.h>
+#include "base/debug/stack_trace.h"
#elif defined(OS_LINUX)
#include <syslog.h>
#endif
-#include <cstring>
#include <ostream>
#include <string>
@@ -24,13 +20,22 @@ namespace logging {
#if defined(OS_WIN)
namespace {
+
std::string* g_event_source_name = nullptr;
-}
+uint16_t g_category = 0;
+uint32_t g_event_id = 0;
+
+} // namespace
-void SetEventSourceName(const std::string& name) {
+void SetEventSource(const std::string& name,
+ uint16_t category,
+ uint32_t 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 +53,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 +80,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)
« no previous file with comments | « base/syslog_logging.h ('k') | base/win/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698