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

Side by Side Diff: base/syslog_logging.cc

Issue 2476353003: Adds eventlog provider dll to describe the message types of SYSLOG. (Closed)
Patch Set: Make the mc file unicode encoded. 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 unified diff | Download patch
« no previous file with comments | « base/BUILD.gn ('k') | base/win/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/debug/stack_trace.h" 5 #include "base/debug/stack_trace.h"
6 #include "base/syslog_logging.h" 6 #include "base/syslog_logging.h"
7 7
8 #if defined(OS_WIN) 8 #if defined(OS_WIN)
9 #include "base/win/eventlog_messages.h"
10
9 #include <windows.h> 11 #include <windows.h>
10 #elif defined(OS_LINUX) 12 #elif defined(OS_LINUX)
11 #include <syslog.h> 13 #include <syslog.h>
12 #endif 14 #endif
13 15
14 #include <cstring> 16 #include <cstring>
15 #include <ostream> 17 #include <ostream>
16 #include <string> 18 #include <string>
17 19
18 namespace logging { 20 namespace logging {
(...skipping 25 matching lines...) Expand all
44 break; 46 break;
45 case LOG_ERROR: 47 case LOG_ERROR:
46 case LOG_FATAL: 48 case LOG_FATAL:
47 // The price of getting the stack trace is not worth the hassle for 49 // The price of getting the stack trace is not worth the hassle for
48 // non-error conditions. 50 // non-error conditions.
49 base::debug::StackTrace trace; 51 base::debug::StackTrace trace;
50 message.append(trace.ToString()); 52 message.append(trace.ToString());
51 log_type = EVENTLOG_ERROR_TYPE; 53 log_type = EVENTLOG_ERROR_TYPE;
52 break; 54 break;
53 } 55 }
54 // TODO(pastarmovj): Register Chrome's event log resource types to make the 56 if (!ReportEventA(event_log_handle, log_type, BROWSER_CATEGORY,
55 // entries nicer. 1337 is just a made up event id type. 57 MSG_LOG_MESSAGE, NULL, 1, 0, strings, NULL)) {
56 if (!ReportEventA(event_log_handle, log_type, 0, 1337, NULL, 1, 0,
57 strings, NULL)) {
58 stream() << " !!NOT ADDED TO EVENTLOG!!"; 58 stream() << " !!NOT ADDED TO EVENTLOG!!";
59 } 59 }
60 DeregisterEventSource(event_log_handle); 60 DeregisterEventSource(event_log_handle);
61 #elif defined(OS_LINUX) 61 #elif defined(OS_LINUX)
62 const char kEventSource[] = "chrome"; 62 const char kEventSource[] = "chrome";
63 openlog(kEventSource, LOG_NOWAIT | LOG_PID, LOG_USER); 63 openlog(kEventSource, LOG_NOWAIT | LOG_PID, LOG_USER);
64 // We can't use the defined names for the logging severity from syslog.h 64 // We can't use the defined names for the logging severity from syslog.h
65 // because they collide with the names of our own severity levels. Therefore 65 // because they collide with the names of our own severity levels. Therefore
66 // we use the actual values which of course do not match ours. 66 // we use the actual values which of course do not match ours.
67 // See sys/syslog.h for reference. 67 // See sys/syslog.h for reference.
(...skipping 11 matching lines...) Expand all
79 case LOG_FATAL: 79 case LOG_FATAL:
80 priority = 2; 80 priority = 2;
81 break; 81 break;
82 } 82 }
83 syslog(priority, "%s", log_message_.str().c_str()); 83 syslog(priority, "%s", log_message_.str().c_str());
84 closelog(); 84 closelog();
85 #endif // defined(OS_WIN) 85 #endif // defined(OS_WIN)
86 } 86 }
87 87
88 } // namespace logging 88 } // namespace logging
OLDNEW
« no previous file with comments | « base/BUILD.gn ('k') | base/win/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698