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

Side by Side Diff: base/syslog_logging.h

Issue 2946983002: Move eventlog_provider from //base/win to //chrome/common/win (Closed)
Patch Set: Address review comments on #4 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 unified diff | Download patch
« no previous file with comments | « base/BUILD.gn ('k') | base/syslog_logging.cc » ('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 #ifndef BASE_SYSLOG_LOGGING_H_ 5 #ifndef BASE_SYSLOG_LOGGING_H_
6 #define BASE_SYSLOG_LOGGING_H_ 6 #define BASE_SYSLOG_LOGGING_H_
7 7
8 #include <iosfwd>
9
8 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "build/build_config.h"
12
13 #if defined(OS_WIN)
14 #include <windows.h>
15 #endif
9 16
10 namespace logging { 17 namespace logging {
11 18
12 // Keep in mind that the syslog is always active regardless of the logging level 19 // Keep in mind that the syslog is always active regardless of the logging level
13 // and applied flags. Use only for important information that a system 20 // and applied flags. Use only for important information that a system
14 // administrator might need to maintain the browser installation. 21 // administrator might need to maintain the browser installation.
15 #define SYSLOG_STREAM(severity) \ 22 #define SYSLOG_STREAM(severity) \
16 COMPACT_GOOGLE_LOG_EX_ ## severity(EventLogMessage).stream() 23 COMPACT_GOOGLE_LOG_EX_ ## severity(EventLogMessage).stream()
17 #define SYSLOG(severity) \ 24 #define SYSLOG(severity) \
18 SYSLOG_STREAM(severity) 25 SYSLOG_STREAM(severity)
19 26
20 // Sets the name of the event source for logging to the Windows Event Log. 27 #if defined(OS_WIN)
21 // Call this function once before using the SYSLOG macro or otherwise it will 28 // Sets the name, category and event id of the event source for logging to the
22 // behave as a regular LOG macro. 29 // Windows Event Log. Call this function once before using the SYSLOG macro or
23 void BASE_EXPORT SetEventSourceName(const std::string& name); 30 // otherwise it will behave as a regular LOG macro.
31 void BASE_EXPORT SetEventSource(const std::string& name,
32 WORD category,
33 DWORD event_id);
Nico 2017/06/22 19:40:27 can you make these uint16_t and uint32_t, so that
proberge 2017/06/22 20:13:23 Done.
34 #endif // defined(OS_WIN)
24 35
25 // Creates a formatted message on the system event log. That would be the 36 // Creates a formatted message on the system event log. That would be the
26 // Application Event log on Windows and the messages log file on POSIX systems. 37 // Application Event log on Windows and the messages log file on POSIX systems.
27 class BASE_EXPORT EventLogMessage { 38 class BASE_EXPORT EventLogMessage {
28 public: 39 public:
29 EventLogMessage(const char* file, int line, LogSeverity severity); 40 EventLogMessage(const char* file, int line, LogSeverity severity);
30 41
31 ~EventLogMessage(); 42 ~EventLogMessage();
32 43
33 std::ostream& stream() { return log_message_.stream(); } 44 std::ostream& stream() { return log_message_.stream(); }
34 45
35 private: 46 private:
36 LogMessage log_message_; 47 LogMessage log_message_;
37 48
38 DISALLOW_COPY_AND_ASSIGN(EventLogMessage); 49 DISALLOW_COPY_AND_ASSIGN(EventLogMessage);
39 }; 50 };
40 51
41 } // namespace logging 52 } // namespace logging
42 53
43 #endif // BASE_SYSLOG_LOGGING_H_ 54 #endif // BASE_SYSLOG_LOGGING_H_
OLDNEW
« no previous file with comments | « base/BUILD.gn ('k') | base/syslog_logging.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698