fixup! [M120 Migration] Notify media device state to webbrowser
[platform/framework/web/chromium-efl.git] / base / syslog_logging.h
1 // Copyright 2016 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef BASE_SYSLOG_LOGGING_H_
6 #define BASE_SYSLOG_LOGGING_H_
7
8 #include <iosfwd>
9
10 #include "base/base_export.h"
11 #include "base/logging.h"
12 #include "build/build_config.h"
13
14 namespace logging {
15
16 // Keep in mind that the syslog is always active regardless of the logging level
17 // and applied flags. Use only for important information that a system
18 // administrator might need to maintain the browser installation.
19 #define SYSLOG_STREAM(severity) \
20   COMPACT_GOOGLE_LOG_EX_ ## severity(EventLogMessage).stream()
21 #define SYSLOG(severity) \
22   SYSLOG_STREAM(severity)
23
24 #if BUILDFLAG(IS_WIN)
25 // Sets the name, category and event id of the event source for logging to the
26 // Windows Event Log. Call this function once before using the SYSLOG macro or
27 // otherwise it will behave as a regular LOG macro.
28 void BASE_EXPORT SetEventSource(const std::string& name,
29                                 uint16_t category,
30                                 uint32_t event_id);
31
32 // The event source may get set more than once in tests.  This function allows
33 // a test to reset the source when needed.
34 void BASE_EXPORT ResetEventSourceForTesting();
35 #endif  // BUILDFLAG(IS_WIN)
36
37 // Creates a formatted message on the system event log. That would be the
38 // Application Event log on Windows and the messages log file on POSIX systems.
39 class BASE_EXPORT EventLogMessage {
40  public:
41   EventLogMessage(const char* file, int line, LogSeverity severity);
42   EventLogMessage(const EventLogMessage&) = delete;
43   EventLogMessage& operator=(const EventLogMessage&) = delete;
44   ~EventLogMessage();
45
46   std::ostream& stream() { return log_message_.stream(); }
47
48  private:
49   LogMessage log_message_;
50 };
51
52 void BASE_EXPORT SetSyslogLoggingForTesting(bool logging_enabled);
53
54 }  // namespace logging
55
56 #endif  // BASE_SYSLOG_LOGGING_H_