RELEASE_LOG should not be Cocoa specific
authorphiln@webkit.org <philn@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 Mar 2020 14:56:07 +0000 (14:56 +0000)
committerphiln@webkit.org <philn@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 Mar 2020 14:56:07 +0000 (14:56 +0000)
https://bugs.webkit.org/show_bug.cgi?id=195182

Reviewed by Konstantin Tokarev.

.:

Add a Systemd Journald Logger implementation, enabled by default
in the GTK and WPE ports. When this is enabled, release logs will
be sent to the Systemd Journal. To retrieve media logs for
instance, this command can be used:

$ journalctl WEBKIT_SUBSYSTEM=WebKitGTK WEBKIT_CHANNEL=Media

* Source/cmake/FindSystemd.cmake: Added.
* Source/cmake/OptionsGTK.cmake:
* Source/cmake/OptionsWPE.cmake:

Source/WebCore:

WPE/GTK build fixes related with Release logging support.

* bridge/npruntime_internal.h:
* dom/ScriptedAnimationController.cpp:
(WebCore::throttlingReasonToString):
* page/PerformanceLogging.cpp:
(WebCore::toString):
* page/PerformanceMonitor.cpp:
(WebCore::stringForCPUSamplingActivityState):
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::MediaPlayerPrivateGStreamer::MediaPlayerPrivateGStreamer):
(WebCore::MediaPlayerPrivateGStreamer::logChannel const):
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h:
(WebCore::MediaPlayerPrivateGStreamer::mediaPlayerLogIdentifier):
(WebCore::MediaPlayerPrivateGStreamer::mediaPlayerLogger):
* platform/graphics/gstreamer/eme/CDMProxyClearKey.cpp:
(WebCore::CDMProxyClearKey::cencDecryptSubsampled):
(WebCore::CDMProxyClearKey::initializeGcrypt):
* platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.h:
* platform/graphics/gstreamer/mse/MediaSourceGStreamer.cpp:
(WebCore::MediaSourceGStreamer::MediaSourceGStreamer):
(WebCore::MediaSourceGStreamer::~MediaSourceGStreamer):
(WebCore::MediaSourceGStreamer::addSourceBuffer):
(WebCore::MediaSourceGStreamer::logChannel const):
* platform/graphics/gstreamer/mse/MediaSourceGStreamer.h:
* platform/graphics/gstreamer/mse/SourceBufferPrivateGStreamer.cpp:
(WebCore::SourceBufferPrivateGStreamer::SourceBufferPrivateGStreamer):
(WebCore::SourceBufferPrivateGStreamer::logChannel const):
* platform/graphics/gstreamer/mse/SourceBufferPrivateGStreamer.h:
* platform/mediastream/AudioMediaStreamTrackRenderer.cpp:
* platform/mediastream/libwebrtc/LibWebRTCProvider.cpp:
(WebCore::computeLogLevel):
* platform/network/soup/NetworkStorageSessionSoup.cpp:
(WebCore::NetworkStorageSession::getRawCookies const):

Source/WTF:

Add sd-journal logging support and wrap the os_log calls with the USE(OS_LOG) guard.

* wtf/Assertions.cpp:
* wtf/Assertions.h:
* wtf/Logger.h:
(WTF::Logger::log):
* wtf/MemoryPressureHandler.cpp:
(WTF::toString):
* wtf/PlatformGTK.cmake:
* wtf/PlatformWPE.cmake:
* wtf/RefCountedLeakCounter.cpp:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@258547 268f45cc-cd09-0410-ab3c-d52691b4dbfc

31 files changed:
ChangeLog
Source/WTF/ChangeLog
Source/WTF/wtf/Assertions.cpp
Source/WTF/wtf/Assertions.h
Source/WTF/wtf/Logger.h
Source/WTF/wtf/LoggerHelper.h
Source/WTF/wtf/MemoryPressureHandler.cpp
Source/WTF/wtf/PlatformGTK.cmake
Source/WTF/wtf/PlatformWPE.cmake
Source/WTF/wtf/RefCountedLeakCounter.cpp
Source/WebCore/ChangeLog
Source/WebCore/bridge/npruntime_internal.h
Source/WebCore/dom/ScriptedAnimationController.cpp
Source/WebCore/page/PerformanceLogging.cpp
Source/WebCore/page/PerformanceMonitor.cpp
Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp
Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h
Source/WebCore/platform/graphics/gstreamer/eme/CDMProxyClearKey.cpp
Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.h
Source/WebCore/platform/graphics/gstreamer/mse/MediaSourceGStreamer.cpp
Source/WebCore/platform/graphics/gstreamer/mse/MediaSourceGStreamer.h
Source/WebCore/platform/graphics/gstreamer/mse/SourceBufferPrivateGStreamer.cpp
Source/WebCore/platform/graphics/gstreamer/mse/SourceBufferPrivateGStreamer.h
Source/WebCore/platform/mediastream/AudioMediaStreamTrackRenderer.cpp
Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProvider.cpp
Source/WebCore/platform/network/soup/NetworkStorageSessionSoup.cpp
Source/cmake/FindSystemd.cmake [new file with mode: 0644]
Source/cmake/OptionsGTK.cmake
Source/cmake/OptionsWPE.cmake
Tools/gtk/install-dependencies
Tools/wpe/install-dependencies

index cbff477..5dcf196 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2020-03-17  Philippe Normand  <pnormand@igalia.com>
+
+        RELEASE_LOG should not be Cocoa specific
+        https://bugs.webkit.org/show_bug.cgi?id=195182
+
+        Reviewed by Konstantin Tokarev.
+
+        Add a Systemd Journald Logger implementation, enabled by default
+        in the GTK and WPE ports. When this is enabled, release logs will
+        be sent to the Systemd Journal. To retrieve media logs for
+        instance, this command can be used:
+
+        $ journalctl WEBKIT_SUBSYSTEM=WebKitGTK WEBKIT_CHANNEL=Media
+
+        * Source/cmake/FindSystemd.cmake: Added.
+        * Source/cmake/OptionsGTK.cmake:
+        * Source/cmake/OptionsWPE.cmake:
+
 2020-03-16  Keith Rollin  <krollin@apple.com>
 
         Remove support for WebKitSystemInterface
index 6a3008d..dccae98 100644 (file)
@@ -1,3 +1,22 @@
+2020-03-17  Philippe Normand  <pnormand@igalia.com>
+
+        RELEASE_LOG should not be Cocoa specific
+        https://bugs.webkit.org/show_bug.cgi?id=195182
+
+        Reviewed by Konstantin Tokarev.
+
+        Add sd-journal logging support and wrap the os_log calls with the USE(OS_LOG) guard.
+
+        * wtf/Assertions.cpp:
+        * wtf/Assertions.h:
+        * wtf/Logger.h:
+        (WTF::Logger::log):
+        * wtf/MemoryPressureHandler.cpp:
+        (WTF::toString):
+        * wtf/PlatformGTK.cmake:
+        * wtf/PlatformWPE.cmake:
+        * wtf/RefCountedLeakCounter.cpp:
+
 2020-03-16  Keith Miller  <keith_miller@apple.com>
 
         JavaScript identifier grammar supports unescaped astral symbols, but JSC doesn’t
index 9ab7809..4073fd5 100644 (file)
 #include <unistd.h>
 #endif
 
+#if USE(JOURNALD)
+#include <wtf/StringPrintStream.h>
+#endif
+
 namespace WTF {
 
 WTF_ATTRIBUTE_PRINTF(1, 0) static String createWithFormatAndArguments(const char* format, va_list args)
@@ -523,7 +527,7 @@ static void setStateOfAllChannels(WTFLogChannel* channels[], size_t channelCount
 
 void WTFInitializeLogChannelStatesFromString(WTFLogChannel* channels[], size_t count, const char* logLevel)
 {
-#if !RELEASE_LOG_DISABLED
+#if USE(OS_LOG) && !RELEASE_LOG_DISABLED
     for (size_t i = 0; i < count; ++i) {
         WTFLogChannel* channel = channels[i];
         channel->osLogChannel = os_log_create(channel->subsystem, channel->name);
@@ -577,12 +581,23 @@ void WTFReleaseLogStackTrace(WTFLogChannel* channel)
         for (int frameNumber = 1; frameNumber < stackTrace->size(); ++frameNumber) {
             auto stackFrame = stack[frameNumber];
             auto demangled = WTF::StackTrace::demangle(stackFrame);
+#if USE(OS_LOG)
             if (demangled && demangled->demangledName())
                 os_log(channel->osLogChannel, "%-3d %p %{public}s", frameNumber, stackFrame, demangled->demangledName());
             else if (demangled && demangled->mangledName())
                 os_log(channel->osLogChannel, "%-3d %p %{public}s", frameNumber, stackFrame, demangled->mangledName());
             else
                 os_log(channel->osLogChannel, "%-3d %p", frameNumber, stackFrame);
+#elif USE(JOURNALD)
+            StringPrintStream out;
+            if (demangled && demangled->demangledName())
+                out.printf("%-3d %p %s", frameNumber, stackFrame, demangled->demangledName());
+            else if (demangled && demangled->mangledName())
+                out.printf("%-3d %p %s", frameNumber, stackFrame, demangled->mangledName());
+            else
+                out.printf("%-3d %p", frameNumber, stackFrame);
+            sd_journal_send("WEBKIT_SUBSYSTEM=%s", channel->subsystem, "WEBKIT_CHANNEL=%s", channel->name, "MESSAGE=%s", out.toCString().data(), nullptr);
+#endif
         }
     }
 }
index b1a73f0..4420b20 100644 (file)
 #include <os/log.h>
 #endif
 
+#if USE(JOURNALD)
+#define SD_JOURNAL_SUPPRESS_LOCATION
+#include <systemd/sd-journal.h>
+#endif
+
 #ifdef __cplusplus
 #include <cstdlib>
 #include <type_traits>
@@ -91,7 +96,11 @@ extern "C" void _ReadWriteBarrier(void);
 #endif
 
 #ifndef RELEASE_LOG_DISABLED
-#define RELEASE_LOG_DISABLED !(USE(OS_LOG))
+#define RELEASE_LOG_DISABLED !(USE(OS_LOG) || USE(JOURNALD))
+#endif
+
+#ifndef VERBOSE_RELEASE_LOG
+#define VERBOSE_RELEASE_LOG USE(JOURNALD)
 #endif
 
 #if COMPILER(GCC_COMPATIBLE)
@@ -154,6 +163,8 @@ typedef struct {
     WTFLogLevel level;
 #if !RELEASE_LOG_DISABLED
     const char* subsystem;
+#endif
+#if USE(OS_LOG) && !RELEASE_LOG_DISABLED
     __unsafe_unretained os_log_t osLogChannel;
 #endif
 } WTFLogChannel;
@@ -163,7 +174,13 @@ typedef struct {
 #define JOIN_LOG_CHANNEL_WITH_PREFIX(prefix, channel) JOIN_LOG_CHANNEL_WITH_PREFIX_LEVEL_2(prefix, channel)
 #define JOIN_LOG_CHANNEL_WITH_PREFIX_LEVEL_2(prefix, channel) prefix ## channel
 
+#if PLATFORM(GTK)
+#define LOG_CHANNEL_WEBKIT_SUBSYSTEM "WebKitGTK"
+#elif PLATFORM(WPE)
+#define LOG_CHANNEL_WEBKIT_SUBSYSTEM "WPEWebKit"
+#else
 #define LOG_CHANNEL_WEBKIT_SUBSYSTEM "com.apple.WebKit"
+#endif
 
 #define DECLARE_LOG_CHANNEL(name) \
     extern WTFLogChannel LOG_CHANNEL(name);
@@ -172,10 +189,15 @@ typedef struct {
 #if RELEASE_LOG_DISABLED
 #define DEFINE_LOG_CHANNEL(name, subsystem) \
     WTFLogChannel LOG_CHANNEL(name) = { (WTFLogChannelState)0, #name, (WTFLogLevel)1 };
-#else
+#endif
+#if USE(OS_LOG) && !RELEASE_LOG_DISABLED
 #define DEFINE_LOG_CHANNEL(name, subsystem) \
     WTFLogChannel LOG_CHANNEL(name) = { (WTFLogChannelState)0, #name, (WTFLogLevel)1, subsystem, OS_LOG_DEFAULT };
 #endif
+#if USE(JOURNALD) && !RELEASE_LOG_DISABLED
+#define DEFINE_LOG_CHANNEL(name, subsystem)                             \
+    WTFLogChannel LOG_CHANNEL(name) = { (WTFLogChannelState)0, #name, (WTFLogLevel)1, subsystem };
+#endif
 #endif
 
 WTF_EXPORT_PRIVATE void WTFReportNotImplementedYet(const char* file, int line, const char* function);
@@ -498,17 +520,14 @@ constexpr bool assertionFailureDueToUnreachableCode = false;
 #define RELEASE_LOG_WITH_LEVEL_IF(isAllowed, channel, level, ...) do { if (isAllowed) RELEASE_LOG_WITH_LEVEL(channel, level, __VA_ARGS__); } while (0)
 
 #define RELEASE_LOG_STACKTRACE(channel) ((void)0)
-#else
+#endif
+
+#if USE(OS_LOG) && !RELEASE_LOG_DISABLED
 #define PUBLIC_LOG_STRING "{public}s"
 #define RELEASE_LOG(channel, ...) os_log(LOG_CHANNEL(channel).osLogChannel, __VA_ARGS__)
 #define RELEASE_LOG_ERROR(channel, ...) os_log_error(LOG_CHANNEL(channel).osLogChannel, __VA_ARGS__)
 #define RELEASE_LOG_FAULT(channel, ...) os_log_fault(LOG_CHANNEL(channel).osLogChannel, __VA_ARGS__)
 #define RELEASE_LOG_INFO(channel, ...) os_log_info(LOG_CHANNEL(channel).osLogChannel, __VA_ARGS__)
-
-#define RELEASE_LOG_IF(isAllowed, channel, ...) do { if (isAllowed) RELEASE_LOG(      channel, __VA_ARGS__); } while (0)
-#define RELEASE_LOG_ERROR_IF(isAllowed, channel, ...) do { if (isAllowed) RELEASE_LOG_ERROR(channel, __VA_ARGS__); } while (0)
-#define RELEASE_LOG_INFO_IF(isAllowed, channel, ...) do { if (isAllowed) RELEASE_LOG_INFO(channel, __VA_ARGS__); } while (0)
-
 #define RELEASE_LOG_WITH_LEVEL(channel, logLevel, ...) do { \
     if (LOG_CHANNEL(channel).level >= (logLevel)) \
         os_log(LOG_CHANNEL(channel).osLogChannel, __VA_ARGS__); \
@@ -518,6 +537,35 @@ constexpr bool assertionFailureDueToUnreachableCode = false;
     if ((isAllowed) && LOG_CHANNEL(channel).level >= (logLevel)) \
         os_log(LOG_CHANNEL(channel).osLogChannel, __VA_ARGS__); \
 } while (0)
+#endif
+
+#if USE(JOURNALD) && !RELEASE_LOG_DISABLED
+#define PUBLIC_LOG_STRING "s"
+#define SD_JOURNAL_SEND(channel, priority, file, line, function, ...) sd_journal_send_with_location("CODE_FILE=" file, "CODE_LINE=" line, function, "WEBKIT_SUBSYSTEM=%s", LOG_CHANNEL(channel).subsystem, "WEBKIT_CHANNEL=%s", LOG_CHANNEL(channel).name, "PRIORITY=%i", priority, "MESSAGE=" __VA_ARGS__, nullptr)
+
+#define _XSTRINGIFY(line) #line
+#define _STRINGIFY(line) _XSTRINGIFY(line)
+#define RELEASE_LOG(channel, ...) SD_JOURNAL_SEND(channel, LOG_NOTICE, __FILE__, _STRINGIFY(__LINE__), __func__, __VA_ARGS__)
+#define RELEASE_LOG_ERROR(channel, ...) SD_JOURNAL_SEND(channel, LOG_ERR, __FILE__, _STRINGIFY(__LINE__), __func__, __VA_ARGS__)
+#define RELEASE_LOG_FAULT(channel, ...) SD_JOURNAL_SEND(channel, LOG_CRIT, __FILE__, _STRINGIFY(__LINE__), __func__, __VA_ARGS__)
+#define RELEASE_LOG_INFO(channel, ...) SD_JOURNAL_SEND(channel, LOG_INFO, __FILE__, _STRINGIFY(__LINE__), __func__, __VA_ARGS__)
+
+#define RELEASE_LOG_WITH_LEVEL(channel, logLevel, ...) do { \
+    if (LOG_CHANNEL(channel).level >= (logLevel)) \
+        SD_JOURNAL_SEND(channel, LOG_INFO, __FILE__, _STRINGIFY(__LINE__), __func__, __VA_ARGS__); \
+} while (0)
+
+#define RELEASE_LOG_WITH_LEVEL_IF(isAllowed, channel, logLevel, ...) do { \
+    if ((isAllowed) && LOG_CHANNEL(channel).level >= (logLevel)) \
+        SD_JOURNAL_SEND(channel, LOG_INFO, __FILE__, _STRINGIFY(__LINE__), __func__, __VA_ARGS__); \
+} while (0)
+#endif
+
+#if !RELEASE_LOG_DISABLED
+#define RELEASE_LOG_STACKTRACE(channel) WTFReleaseLogStackTrace(&LOG_CHANNEL(channel))
+#define RELEASE_LOG_IF(isAllowed, channel, ...) do { if (isAllowed) RELEASE_LOG(channel, __VA_ARGS__); } while (0)
+#define RELEASE_LOG_ERROR_IF(isAllowed, channel, ...) do { if (isAllowed) RELEASE_LOG_ERROR(channel, __VA_ARGS__); } while (0)
+#define RELEASE_LOG_INFO_IF(isAllowed, channel, ...) do { if (isAllowed) RELEASE_LOG_INFO(channel, __VA_ARGS__); } while (0)
 
 #define RELEASE_LOG_STACKTRACE(channel) WTFReleaseLogStackTrace(&LOG_CHANNEL(channel))
 #endif
index 4f238ce..5a6bf56 100644 (file)
 #include <wtf/ThreadSafeRefCounted.h>
 #include <wtf/text/StringBuilder.h>
 
+#if USE(JOURNALD)
+#define SD_JOURNAL_SUPPRESS_LOCATION
+#include <systemd/sd-journal.h>
+#endif
+
 namespace WTF {
 
 template<typename T>
@@ -174,6 +179,57 @@ public:
         log(channel, WTFLogLevel::Debug, arguments...);
     }
 
+    template<typename... Arguments>
+    inline void logAlwaysVerbose(WTFLogChannel& channel, const char* file, const char* function, int line, UNUSED_FUNCTION const Arguments&... arguments) const
+    {
+#if RELEASE_LOG_DISABLED
+        // "Standard" WebCore logging goes to stderr, which is captured in layout test output and can generally be a problem
+        //  on some systems, so don't allow it.
+        UNUSED_PARAM(channel);
+#else
+        if (!willLog(channel, WTFLogLevel::Always))
+            return;
+
+        logVerbose(channel, WTFLogLevel::Always, file, function, line, arguments...);
+#endif
+    }
+
+    template<typename... Arguments>
+    inline void errorVerbose(WTFLogChannel& channel, const char* file, const char* function, int line, const Arguments&... arguments) const
+    {
+        if (!willLog(channel, WTFLogLevel::Error))
+            return;
+
+        logVerbose(channel, WTFLogLevel::Error, file, function, line, arguments...);
+    }
+
+    template<typename... Arguments>
+    inline void warningVerbose(WTFLogChannel& channel, const char* file, const char* function, int line, const Arguments&... arguments) const
+    {
+        if (!willLog(channel, WTFLogLevel::Warning))
+            return;
+
+        logVerbose(channel, WTFLogLevel::Warning, file, function, line, arguments...);
+    }
+
+    template<typename... Arguments>
+    inline void infoVerbose(WTFLogChannel& channel, const char* file, const char* function, int line, const Arguments&... arguments) const
+    {
+        if (!willLog(channel, WTFLogLevel::Info))
+            return;
+
+        logVerbose(channel, WTFLogLevel::Info, file, function, line, arguments...);
+    }
+
+    template<typename... Arguments>
+    inline void debugVerbose(WTFLogChannel& channel, const char* file, const char* function, int line, const Arguments&... arguments) const
+    {
+        if (!willLog(channel, WTFLogLevel::Debug))
+            return;
+
+        logVerbose(channel, WTFLogLevel::Debug, file, function, line, arguments...);
+    }
+
     inline bool willLog(const WTFLogChannel& channel, WTFLogLevel level) const
     {
         if (!m_enabled)
@@ -245,9 +301,44 @@ private:
 
 #if RELEASE_LOG_DISABLED
         WTFLog(&channel, "%s", logMessage.utf8().data());
-#else
+#endif
+#if USE(OS_LOG) && !RELEASE_LOG_DISABLED
         os_log(channel.osLogChannel, "%{public}s", logMessage.utf8().data());
 #endif
+#if USE(JOURNALD) && !RELEASE_LOG_DISABLED
+        sd_journal_send("WEBKIT_SUBSYSTEM=%s", channel.subsystem, "WEBKIT_CHANNEL=%s", channel.name, "MESSAGE=%s", logMessage.utf8().data(), nullptr);
+#endif
+
+        if (channel.state == WTFLogChannelState::Off || level > channel.level)
+            return;
+
+        auto lock = tryHoldLock(observerLock());
+        if (!lock)
+            return;
+
+        for (Observer& observer : observers())
+            observer.didLogMessage(channel, level, { ConsoleLogValue<Argument>::toValue(arguments)... });
+    }
+
+    template<typename... Argument>
+    static inline void logVerbose(WTFLogChannel& channel, WTFLogLevel level, const char* file, const char* function, int line, const Argument&... arguments)
+    {
+        String logMessage = makeString(LogArgument<Argument>::toString(arguments)...);
+
+#if RELEASE_LOG_DISABLED
+        WTFLogVerbose(file, line, function, &channel, "%s", logMessage.utf8().data());
+#endif
+#if USE(OS_LOG) && !RELEASE_LOG_DISABLED
+        os_log(channel.osLogChannel, "%{public}s", logMessage.utf8().data());
+        UNUSED_PARAM(file);
+        UNUSED_PARAM(line);
+        UNUSED_PARAM(function);
+#endif
+#if USE(JOURNALD) && !RELEASE_LOG_DISABLED
+        auto fileString = makeString("CODE_FILE=", file);
+        auto lineString = makeString("CODE_LINE=", line);
+        sd_journal_send_with_location(fileString.utf8().data(), lineString.utf8().data(), function, "WEBKIT_SUBSYSTEM=%s", channel.subsystem, "WEBKIT_CHANNEL=%s", channel.name, "MESSAGE=%s", logMessage.utf8().data(), nullptr);
+#endif
 
         if (channel.state == WTFLogChannelState::Off || level > channel.level)
             return;
index 0ad65ee..9eb73ba 100644 (file)
@@ -43,18 +43,27 @@ public:
 
 #define LOGIDENTIFIER WTF::Logger::LogSiteIdentifier(logClassName(), __func__, logIdentifier())
 
+#if VERBOSE_RELEASE_LOG
+#define ALWAYS_LOG(...)     logger().logAlwaysVerbose(logChannel(), __FILE__, __func__, __LINE__, __VA_ARGS__)
+#define ERROR_LOG(...)      logger().errorVerbose(logChannel(), __FILE__, __func__, __LINE__, __VA_ARGS__)
+#define WARNING_LOG(...)    logger().warningVerbose(logChannel(), __FILE__, __func__, __LINE__, __VA_ARGS__)
+#define INFO_LOG(...)       logger().infoVerbose(logChannel(), __FILE__, __func__, __LINE__, __VA_ARGS__)
+#define DEBUG_LOG(...)      logger().debugVerbose(logChannel(), __FILE__, __func__, __LINE__, __VA_ARGS__)
+#else
 #define ALWAYS_LOG(...)     logger().logAlways(logChannel(), __VA_ARGS__)
 #define ERROR_LOG(...)      logger().error(logChannel(), __VA_ARGS__)
 #define WARNING_LOG(...)    logger().warning(logChannel(), __VA_ARGS__)
 #define INFO_LOG(...)       logger().info(logChannel(), __VA_ARGS__)
 #define DEBUG_LOG(...)      logger().debug(logChannel(), __VA_ARGS__)
+#endif
+
 #define WILL_LOG(_level_)   logger().willLog(logChannel(), _level_)
 
-#define ALWAYS_LOG_IF(condition, ...)     if (condition) logger().logAlways(logChannel(), __VA_ARGS__)
-#define ERROR_LOG_IF(condition, ...)      if (condition) logger().error(logChannel(), __VA_ARGS__)
-#define WARNING_LOG_IF(condition, ...)    if (condition) logger().warning(logChannel(), __VA_ARGS__)
-#define INFO_LOG_IF(condition, ...)       if (condition) logger().info(logChannel(), __VA_ARGS__)
-#define DEBUG_LOG_IF(condition, ...)      if (condition) logger().debug(logChannel(), __VA_ARGS__)
+#define ALWAYS_LOG_IF(condition, ...)     if (condition) ALWAYS_LOG(__VA_ARGS__)
+#define ERROR_LOG_IF(condition, ...)      if (condition) ERROR_LOG(__VA_ARGS__)
+#define WARNING_LOG_IF(condition, ...)    if (condition) WARNING_LOG(__VA_ARGS__)
+#define INFO_LOG_IF(condition, ...)       if (condition) INFO_LOG(__VA_ARGS__)
+#define DEBUG_LOG_IF(condition, ...)      if (condition) DEBUG_LOG(__VA_ARGS__)
 
 #define ALWAYS_LOG_IF_POSSIBLE(...)     if (loggerPtr()) loggerPtr()->logAlways(logChannel(), __VA_ARGS__)
 #define ERROR_LOG_IF_POSSIBLE(...)      if (loggerPtr()) loggerPtr()->error(logChannel(), __VA_ARGS__)
index 135756d..c280160 100644 (file)
@@ -36,9 +36,13 @@ namespace WTF {
 
 #if RELEASE_LOG_DISABLED
 WTFLogChannel LogMemoryPressure = { WTFLogChannelState::On, "MemoryPressure", WTFLogLevel::Error };
-#else
+#endif
+#if USE(OS_LOG) && !RELEASE_LOG_DISABLED
 WTFLogChannel LogMemoryPressure = { WTFLogChannelState::On, "MemoryPressure", WTFLogLevel::Error, LOG_CHANNEL_WEBKIT_SUBSYSTEM, OS_LOG_DEFAULT };
 #endif
+#if USE(JOURNALD) && !RELEASE_LOG_DISABLED
+WTFLogChannel LogMemoryPressure = { WTFLogChannelState::On, "MemoryPressure", WTFLogLevel::Error, LOG_CHANNEL_WEBKIT_SUBSYSTEM };
+#endif
 
 WTF_EXPORT_PRIVATE bool MemoryPressureHandler::ReliefLogger::s_loggingEnabled = false;
 
@@ -83,6 +87,8 @@ static const char* toString(MemoryUsagePolicy policy)
     case MemoryUsagePolicy::Conservative: return "Conservative";
     case MemoryUsagePolicy::Strict: return "Strict";
     }
+    ASSERT_NOT_REACHED();
+    return "";
 }
 #endif
 
index a8d9792..f1a8e88 100644 (file)
@@ -62,6 +62,10 @@ list(APPEND WTF_LIBRARIES
     ZLIB::ZLIB
 )
 
+if (Systemd_FOUND)
+    list(APPEND WTF_LIBRARIES Systemd::Systemd)
+endif ()
+
 list(APPEND WTF_SYSTEM_INCLUDE_DIRECTORIES
     ${GIO_UNIX_INCLUDE_DIRS}
     ${GLIB_INCLUDE_DIRS}
index e5a8ff4..de47410 100644 (file)
@@ -47,6 +47,10 @@ list(APPEND WTF_LIBRARIES
     ZLIB::ZLIB
 )
 
+if (Systemd_FOUND)
+    list(APPEND WTF_LIBRARIES Systemd::Systemd)
+endif ()
+
 list(APPEND WTF_SYSTEM_INCLUDE_DIRECTORIES
     ${GIO_UNIX_INCLUDE_DIRS}
     ${GLIB_INCLUDE_DIRS}
index e33facb..9cf03bc 100644 (file)
@@ -41,9 +41,13 @@ void RefCountedLeakCounter::decrement() { }
 #define LOG_CHANNEL_PREFIX Log
 #if RELEASE_LOG_DISABLED
 static WTFLogChannel LogRefCountedLeaks = { WTFLogChannelState::On, "RefCountedLeaks", WTFLogLevel::Error };
-#else
+#endif
+#if USE(OS_LOG) && !RELEASE_LOG_DISABLED
 static WTFLogChannel LogRefCountedLeaks = { WTFLogChannelState::On, "RefCountedLeaks", WTFLogLevel::Error, LOG_CHANNEL_WEBKIT_SUBSYSTEM, OS_LOG_DEFAULT };
 #endif
+#if USE(JOURNALD) && !RELEASE_LOG_DISABLED
+static WTFLogChannel LogRefCountedLeaks = { WTFLogChannelState::On, "RefCountedLeaks", WTFLogLevel::Error, LOG_CHANNEL_WEBKIT_SUBSYSTEM };
+#endif
 
 typedef HashCountedSet<const char*, PtrHash<const char*>> ReasonSet;
 static ReasonSet* leakMessageSuppressionReasons;
index b467a47..5cf6d6a 100644 (file)
@@ -1,3 +1,45 @@
+2020-03-17  Philippe Normand  <pnormand@igalia.com>
+
+        RELEASE_LOG should not be Cocoa specific
+        https://bugs.webkit.org/show_bug.cgi?id=195182
+
+        Reviewed by Konstantin Tokarev.
+
+        WPE/GTK build fixes related with Release logging support.
+
+        * bridge/npruntime_internal.h:
+        * dom/ScriptedAnimationController.cpp:
+        (WebCore::throttlingReasonToString):
+        * page/PerformanceLogging.cpp:
+        (WebCore::toString):
+        * page/PerformanceMonitor.cpp:
+        (WebCore::stringForCPUSamplingActivityState):
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
+        (WebCore::MediaPlayerPrivateGStreamer::MediaPlayerPrivateGStreamer):
+        (WebCore::MediaPlayerPrivateGStreamer::logChannel const):
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h:
+        (WebCore::MediaPlayerPrivateGStreamer::mediaPlayerLogIdentifier):
+        (WebCore::MediaPlayerPrivateGStreamer::mediaPlayerLogger):
+        * platform/graphics/gstreamer/eme/CDMProxyClearKey.cpp:
+        (WebCore::CDMProxyClearKey::cencDecryptSubsampled):
+        (WebCore::CDMProxyClearKey::initializeGcrypt):
+        * platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.h:
+        * platform/graphics/gstreamer/mse/MediaSourceGStreamer.cpp:
+        (WebCore::MediaSourceGStreamer::MediaSourceGStreamer):
+        (WebCore::MediaSourceGStreamer::~MediaSourceGStreamer):
+        (WebCore::MediaSourceGStreamer::addSourceBuffer):
+        (WebCore::MediaSourceGStreamer::logChannel const):
+        * platform/graphics/gstreamer/mse/MediaSourceGStreamer.h:
+        * platform/graphics/gstreamer/mse/SourceBufferPrivateGStreamer.cpp:
+        (WebCore::SourceBufferPrivateGStreamer::SourceBufferPrivateGStreamer):
+        (WebCore::SourceBufferPrivateGStreamer::logChannel const):
+        * platform/graphics/gstreamer/mse/SourceBufferPrivateGStreamer.h:
+        * platform/mediastream/AudioMediaStreamTrackRenderer.cpp:
+        * platform/mediastream/libwebrtc/LibWebRTCProvider.cpp:
+        (WebCore::computeLogLevel):
+        * platform/network/soup/NetworkStorageSessionSoup.cpp:
+        (WebCore::NetworkStorageSession::getRawCookies const):
+
 2020-03-17  youenn fablet  <youenn@apple.com>
 
         Safari doesn't insert mDNS candidates to SDP
index 3dee6ca..598f9dd 100644 (file)
@@ -35,6 +35,7 @@
 #if defined(MOZ_X11)
     #include <X11/Xresource.h>
 
+    #undef Always
     #undef None
     #undef Above
     #undef Below
index 014d4cd..cdfdfb9 100644 (file)
@@ -97,6 +97,8 @@ static const char* throttlingReasonToString(ScriptedAnimationController::Throttl
     case ScriptedAnimationController::ThrottlingReason::NonInteractedCrossOriginFrame:
         return "NonInteractiveCrossOriginFrame";
     }
+    RELEASE_ASSERT_NOT_REACHED();
+    return "";
 }
 
 static String throttlingReasonsToString(OptionSet<ScriptedAnimationController::ThrottlingReason> reasons)
index bed2679..c1c8d1a 100644 (file)
@@ -48,6 +48,8 @@ static const char* toString(PerformanceLogging::PointOfInterest poi)
     case PerformanceLogging::MainFrameLoadCompleted:
         return "MainFrameLoadCompleted";
     }
+    RELEASE_ASSERT_NOT_REACHED();
+    return "";
 }
 #endif
 
index e645ab9..f85fbed 100644 (file)
@@ -262,6 +262,8 @@ static inline const char* stringForCPUSamplingActivityState(ActivityStateForCPUS
     case ActivityStateForCPUSampling::VisibleAndActive:
         return "VisibleAndActive";
     }
+    RELEASE_ASSERT_NOT_REACHED();
+    return "";
 }
 
 #endif
index 8c50c22..b107563 100644 (file)
@@ -425,15 +425,16 @@ MediaPlayerPrivateGStreamer::MediaPlayerPrivateGStreamer(MediaPlayer* player)
     , m_preload(player->preload())
     , m_maxTimeLoadedAtLastDidLoadingProgress(MediaTime::zeroTime())
     , m_drawTimer(RunLoop::main(), this, &MediaPlayerPrivateGStreamer::repaint)
-    , m_readyTimerHandler(RunLoop::main(), this, &MediaPlayerPrivateGStreamer::readyTimerFired
-)
+    , m_readyTimerHandler(RunLoop::main(), this, &MediaPlayerPrivateGStreamer::readyTimerFired)
 #if USE(TEXTURE_MAPPER_GL)
 #if USE(NICOSIA)
     , m_nicosiaLayer(Nicosia::ContentLayer::create(Nicosia::ContentLayerTextureMapperImpl::createFactory(*this)))
 #else
     , m_platformLayerProxy(adoptRef(new TextureMapperPlatformLayerProxy()))
 #endif
-#endif      
+#endif
+    , m_logger(player->mediaPlayerLogger())
+    , m_logIdentifier(player->mediaPlayerLogIdentifier())
 {
 #if USE(GLIB)
     m_readyTimerHandler.setPriority(G_PRIORITY_DEFAULT_IDLE);
@@ -3838,6 +3839,11 @@ MediaPlayer::SupportsType MediaPlayerPrivateGStreamer::extendedSupportsType(cons
     return result;
 }
 
+WTFLogChannel& MediaPlayerPrivateGStreamer::logChannel() const
+{
+    return WebCore::LogMedia;
+}
+
 }
 
 #endif // USE(GSTREAMER)
index cc579e2..ae51b75 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "GStreamerCommon.h"
 #include "GStreamerEMEUtilities.h"
+#include "Logging.h"
 #include "MainThreadNotifier.h"
 #include "MediaPlayerPrivate.h"
 #include "PlatformLayer.h"
@@ -37,6 +38,7 @@
 #include <wtf/Atomics.h>
 #include <wtf/Condition.h>
 #include <wtf/Forward.h>
+#include <wtf/LoggerHelper.h>
 #include <wtf/RunLoop.h>
 #include <wtf/WeakPtr.h>
 
@@ -115,7 +117,9 @@ class VideoTrackPrivateGStreamer;
 void registerWebKitGStreamerElements();
 
 // Use eager initialization for the WeakPtrFactory since we call makeWeakPtr() from another thread.
-class MediaPlayerPrivateGStreamer : public MediaPlayerPrivateInterface, public CanMakeWeakPtr<MediaPlayerPrivateGStreamer, WeakPtrFactoryInitialization::Eager>
+class MediaPlayerPrivateGStreamer : public MediaPlayerPrivateInterface
+    , public CanMakeWeakPtr<MediaPlayerPrivateGStreamer, WeakPtrFactoryInitialization::Eager>
+    , private LoggerHelper
 #if USE(TEXTURE_MAPPER_GL)
 #if USE(NICOSIA)
     , public Nicosia::ContentLayerTextureMapperImpl::Client
@@ -226,6 +230,14 @@ public:
     void flushCurrentBuffer();
 #endif
 
+    const Logger& logger() const final { return m_logger; }
+    const char* logClassName() const override { return "MediaPlayerPrivateGStreamer"; }
+    const void* logIdentifier() const final { return reinterpret_cast<const void*>(m_logIdentifier); }
+    WTFLogChannel& logChannel() const override;
+
+    const void* mediaPlayerLogIdentifier() { return logIdentifier(); }
+    const Logger& mediaPlayerLogger() { return logger(); }
+
 protected:
     enum MainThreadNotification {
         VideoChanged = 1 << 0,
@@ -529,6 +541,8 @@ private:
 #if USE(WPE_VIDEO_PLANE_DISPLAY_DMABUF)
     GUniquePtr<struct wpe_video_plane_display_dmabuf_source> m_wpeVideoPlaneDisplayDmaBuf;
 #endif
+    Ref<const Logger> m_logger;
+    const void* m_logIdentifier;
 };
 
 }
index 6c4250d..c1b6b34 100644 (file)
@@ -171,7 +171,11 @@ bool CDMProxyClearKey::cencDecryptSubsampled(cencDecryptContext& input)
             LOG(EME, "EME - subsample index %u - %u bytes encrypted (%lu bytes left to decrypt)", subsampleIndex, subsampleNumEncryptedBytes, input.encryptedBufferSizeInBytes - encryptedBufferByteOffset);
 
             if (gcry_error_t cipherError = gcry_cipher_decrypt(m_gcryHandle, input.encryptedBuffer + encryptedBufferByteOffset, subsampleNumEncryptedBytes, 0, 0)) {
+#if !LOG_DISABLED
                 LOG(EME, "EME - CDMProxyClearKey - ERROR(gcry_cipher_decrypt): %s", gpg_strerror(cipherError));
+#else
+                UNUSED_VARIABLE(cipherError);
+#endif
                 return false;
             }
 
@@ -193,7 +197,11 @@ bool CDMProxyClearKey::cencDecrypt(CDMProxyClearKey::cencDecryptContext& input)
 void CDMProxyClearKey::initializeGcrypt()
 {
     if (gcry_error_t error = gcry_cipher_open(&m_gcryHandle, GCRY_CIPHER_AES128, GCRY_CIPHER_MODE_CTR, GCRY_CIPHER_SECURE)) {
+#if !LOG_DISABLED
         LOG(EME, "EME - CDMProxyClearKey - ERROR(gcry_cipher_open): %s", gpg_strerror(error));
+#else
+        UNUSED_VARIABLE(error);
+#endif
         RELEASE_ASSERT(false && "Should not get this far with a functional GCrypt!");
     }
 }
index 4ddf2bf..fc67428 100644 (file)
@@ -83,6 +83,8 @@ public:
     void blockDurationChanges();
     void unblockDurationChanges();
 
+    WTFLogChannel& logChannel() const final { return WebCore::LogMediaSource; }
+
 private:
     friend class MediaPlayerFactoryGStreamerMSE;
     static void getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>&);
index e62cd56..c8f5805 100644 (file)
@@ -38,6 +38,7 @@
 #if ENABLE(MEDIA_SOURCE) && USE(GSTREAMER)
 
 #include "ContentType.h"
+#include "Logging.h"
 #include "MediaPlayerPrivateGStreamer.h"
 #include "MediaPlayerPrivateGStreamerMSE.h"
 #include "MediaSourceClientGStreamerMSE.h"
@@ -60,17 +61,23 @@ MediaSourceGStreamer::MediaSourceGStreamer(MediaSourcePrivateClient& mediaSource
     , m_client(MediaSourceClientGStreamerMSE::create(playerPrivate))
     , m_mediaSource(mediaSource)
     , m_playerPrivate(playerPrivate)
+#if !RELEASE_LOG_DISABLED
+    , m_logger(m_playerPrivate.mediaPlayerLogger())
+    , m_logIdentifier(m_playerPrivate.mediaPlayerLogIdentifier())
+#endif
 {
 }
 
 MediaSourceGStreamer::~MediaSourceGStreamer()
 {
+    ALWAYS_LOG(LOGIDENTIFIER);
     for (auto& sourceBufferPrivate : m_sourceBuffers)
         sourceBufferPrivate->clearMediaSource();
 }
 
 MediaSourceGStreamer::AddStatus MediaSourceGStreamer::addSourceBuffer(const ContentType& contentType, RefPtr<SourceBufferPrivate>& sourceBufferPrivate)
 {
+    DEBUG_LOG(LOGIDENTIFIER, contentType);
     sourceBufferPrivate = SourceBufferPrivateGStreamer::create(this, m_client.get(), contentType);
     RefPtr<SourceBufferPrivateGStreamer> sourceBufferPrivateGStreamer = static_cast<SourceBufferPrivateGStreamer*>(sourceBufferPrivate.get());
     m_sourceBuffers.add(sourceBufferPrivateGStreamer);
@@ -135,5 +142,13 @@ std::unique_ptr<PlatformTimeRanges> MediaSourceGStreamer::buffered()
     return m_mediaSource->buffered();
 }
 
+#if !RELEASE_LOG_DISABLED
+WTFLogChannel& MediaSourceGStreamer::logChannel() const
+{
+    return LogMediaSource;
+}
+
+#endif
+
 }
 #endif
index c9a09fa..51cab2e 100644 (file)
@@ -39,6 +39,7 @@
 
 #include <wtf/Forward.h>
 #include <wtf/HashSet.h>
+#include <wtf/LoggerHelper.h>
 
 typedef struct _WebKitMediaSrc WebKitMediaSrc;
 
@@ -50,7 +51,11 @@ class MediaPlayerPrivateGStreamerMSE;
 class PlatformTimeRanges;
 
 // FIXME: Should this be called MediaSourcePrivateGStreamer?
-class MediaSourceGStreamer final : public MediaSourcePrivate {
+class MediaSourceGStreamer final : public MediaSourcePrivate
+#if !RELEASE_LOG_DISABLED
+    , private LoggerHelper
+#endif
+{
 public:
     static void open(MediaSourcePrivateClient&, MediaPlayerPrivateGStreamerMSE&);
     virtual ~MediaSourceGStreamer();
@@ -73,6 +78,15 @@ public:
 
     std::unique_ptr<PlatformTimeRanges> buffered();
 
+#if !RELEASE_LOG_DISABLED
+    const Logger& logger() const final { return m_logger; }
+    const char* logClassName() const override { return "MediaSourcePrivateGStreamer"; }
+    const void* logIdentifier() const final { return m_logIdentifier; }
+    WTFLogChannel& logChannel() const final;
+
+    const void* nextSourceBufferLogIdentifier() { return childLogIdentifier(m_logIdentifier, ++m_nextSourceBufferID); }
+#endif
+
 private:
     MediaSourceGStreamer(MediaSourcePrivateClient&, MediaPlayerPrivateGStreamerMSE&);
 
@@ -81,6 +95,11 @@ private:
     Ref<MediaSourceClientGStreamerMSE> m_client;
     Ref<MediaSourcePrivateClient> m_mediaSource;
     MediaPlayerPrivateGStreamerMSE& m_playerPrivate;
+#if !RELEASE_LOG_DISABLED
+    Ref<const Logger> m_logger;
+    const void* m_logIdentifier;
+    uint64_t m_nextSourceBufferID { 0 };
+#endif
 };
 
 }
index 7c1e799..720d344 100644 (file)
@@ -58,6 +58,10 @@ SourceBufferPrivateGStreamer::SourceBufferPrivateGStreamer(MediaSourceGStreamer*
     , m_mediaSource(mediaSource)
     , m_type(contentType)
     , m_client(client.get())
+#if !RELEASE_LOG_DISABLED
+    , m_logger(mediaSource->logger())
+    , m_logIdentifier(mediaSource->nextSourceBufferLogIdentifier())
+#endif
 {
 }
 
@@ -177,5 +181,12 @@ void SourceBufferPrivateGStreamer::appendParsingFailed()
         m_sourceBufferPrivateClient->sourceBufferPrivateAppendComplete(SourceBufferPrivateClient::ParsingFailed);
 }
 
+#if !RELEASE_LOG_DISABLED
+WTFLogChannel& SourceBufferPrivateGStreamer::logChannel() const
+{
+    return LogMediaSource;
+}
+#endif
+
 }
 #endif
index e5fe406..5321ddc 100644 (file)
 #include "SourceBufferPrivate.h"
 #include "SourceBufferPrivateClient.h"
 #include "WebKitMediaSourceGStreamer.h"
+#include <wtf/LoggerHelper.h>
 
 namespace WebCore {
 
 class MediaSourceGStreamer;
 
-class SourceBufferPrivateGStreamer final : public SourceBufferPrivate {
+class SourceBufferPrivateGStreamer final : public SourceBufferPrivate
+#if !RELEASE_LOG_DISABLED
+    , private LoggerHelper
+#endif
+{
 
 public:
     static Ref<SourceBufferPrivateGStreamer> create(MediaSourceGStreamer*, Ref<MediaSourceClientGStreamerMSE>, const ContentType&);
@@ -79,6 +84,15 @@ public:
 
     ContentType type() const { return m_type; }
 
+#if !RELEASE_LOG_DISABLED
+    const Logger& logger() const final { return m_logger.get(); }
+    const char* logClassName() const override { return "SourceBufferPrivateGStreamer"; }
+    const void* logIdentifier() const final { return m_logIdentifier; }
+    WTFLogChannel& logChannel() const final;
+    const Logger& sourceBufferLogger() const final { return m_logger; }
+    const void* sourceBufferLogIdentifier() final { return logIdentifier(); }
+#endif
+
 private:
     SourceBufferPrivateGStreamer(MediaSourceGStreamer*, Ref<MediaSourceClientGStreamerMSE>, const ContentType&);
     friend class MediaSourceClientGStreamerMSE;
@@ -90,6 +104,11 @@ private:
     bool m_isReadyForMoreSamples = true;
     bool m_notifyWhenReadyForMoreSamples = false;
     AtomString m_trackId;
+
+#if !RELEASE_LOG_DISABLED
+    Ref<const Logger> m_logger;
+    const void* m_logIdentifier;
+#endif
 };
 
 }
index b51649a..51f05d8 100644 (file)
@@ -28,6 +28,8 @@
 
 #if ENABLE(VIDEO_TRACK) && ENABLE(MEDIA_STREAM)
 
+#include "Logging.h"
+
 #if PLATFORM(COCOA)
 #include "AudioMediaStreamTrackRendererCocoa.h"
 #endif
index 1c40939..64db2b4 100644 (file)
@@ -157,6 +157,8 @@ static rtc::LoggingSeverity computeLogLevel()
     case WTFLogLevel::Debug:
         return rtc::LS_VERBOSE;
     }
+    RELEASE_ASSERT_NOT_REACHED();
+    return rtc::LS_NONE;
 #else
     return rtc::LS_NONE;
 #endif
index 914e10e..4fdbbab 100644 (file)
@@ -471,6 +471,7 @@ bool NetworkStorageSession::getRawCookies(const URL& firstParty, const SameSiteI
     GUniquePtr<GSList> cookies(soup_cookie_jar_get_cookie_list(cookieStorage(), uri.get(), TRUE));
     UNUSED_PARAM(firstParty);
     UNUSED_PARAM(sameSiteInfo);
+    UNUSED_PARAM(firstParty);
 #endif
     if (!cookies)
         return false;
diff --git a/Source/cmake/FindSystemd.cmake b/Source/cmake/FindSystemd.cmake
new file mode 100644 (file)
index 0000000..381f922
--- /dev/null
@@ -0,0 +1,92 @@
+# Copyright (C) 2020 Igalia S.L.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1.  Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer.
+# 2.  Redistributions in binary form must reproduce the above copyright
+#     notice, this list of conditions and the following disclaimer in the
+#     documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND ITS CONTRIBUTORS ``AS
+# IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR ITS
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#[=======================================================================[.rst:
+FindSystemd
+-----------
+
+Find Systemd headers and libraries.
+
+Imported Targets
+^^^^^^^^^^^^^^^^
+
+``Systemd::Systemd``
+  The Systemd library, if found.
+
+Result Variables
+^^^^^^^^^^^^^^^^
+
+This will define the following variables in your project:
+
+``Systemd_FOUND``
+  true if (the requested version of) Systemd is available.
+``Systemd_VERSION``
+  the version of Systemd.
+``Systemd_LIBRARIES``
+  the libraries to link against to use Systemd.
+``Systemd_INCLUDE_DIRS``
+  where to find the Systemd headers.
+``Systemd_COMPILE_OPTIONS``
+  this should be passed to target_compile_options(), if the
+  target is not used for linking
+
+#]=======================================================================]
+
+find_package(PkgConfig QUIET)
+
+pkg_check_modules(PC_SYSTEMD QUIET libsystemd)
+set(Systemd_COMPILE_OPTIONS ${PC_SYSTEMD_CFLAGS_OTHER})
+set(Systemd_VERSION ${PC_SYSTEMD_VERSION})
+
+find_path(Systemd_INCLUDE_DIR
+    NAMES systemd/sd-journal.h
+    HINTS ${PC_SYSTEMD_INCLUDEDIR} ${PC_SYSTEMD_INCLUDE_DIRS}
+)
+
+find_library(Systemd_LIBRARY
+    NAMES ${Systemd_NAMES} systemd
+    HINTS ${PC_SYSTEMD_LIBDIR} ${PC_SYSTEMD_LIBRARY_DIRS}
+)
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(Systemd
+    FOUND_VAR Systemd_FOUND
+    REQUIRED_VARS Systemd_LIBRARY Systemd_INCLUDE_DIR
+    VERSION_VAR Systemd_VERSION
+)
+
+if (Systemd_LIBRARY AND NOT TARGET Systemd::Systemd)
+    add_library(Systemd::Systemd UNKNOWN IMPORTED GLOBAL)
+    set_target_properties(Systemd::Systemd PROPERTIES
+        IMPORTED_LOCATION "${Systemd_LIBRARY}"
+        INTERFACE_COMPILE_OPTIONS "${Systemd_COMPILE_OPTIONS}"
+        INTERFACE_INCLUDE_DIRECTORIES "${Systemd_INCLUDE_DIR}"
+    )
+endif ()
+
+mark_as_advanced(Systemd_INCLUDE_DIR Systemd_LIBRARY)
+
+if (Systemd_FOUND)
+    set(Systemd_LIBRARIES ${Systemd_LIBRARY})
+    set(Systemd_INCLUDE_DIRS ${Systemd_INCLUDE_DIR})
+endif ()
index 5cb2ec1..fd367b8 100644 (file)
@@ -87,6 +87,7 @@ WEBKIT_OPTION_DEFINE(USE_LIBSECRET "Whether to enable the persistent credential
 WEBKIT_OPTION_DEFINE(USE_OPENJPEG "Whether to enable support for JPEG2000 images." PUBLIC ON)
 WEBKIT_OPTION_DEFINE(USE_WOFF2 "Whether to enable support for WOFF2 Web Fonts." PUBLIC ON)
 WEBKIT_OPTION_DEFINE(USE_WPE_RENDERER "Whether to enable WPE rendering" PUBLIC ON)
+WEBKIT_OPTION_DEFINE(USE_SYSTEMD "Whether to enable journald logging" PUBLIC ON)
 
 # Private options specific to the GTK port. Changing these options is
 # completely unsupported. They are intended for use only by WebKit developers.
@@ -386,6 +387,16 @@ if (USE_WOFF2)
     endif ()
 endif ()
 
+if (USE_SYSTEMD)
+    find_package(Systemd)
+    if (Systemd_FOUND)
+        message(STATUS "Release logs will be sent to the Systemd journal")
+        SET_AND_EXPOSE_TO_BUILD(USE_JOURNALD TRUE)
+    else ()
+        message(FATAL_ERROR "libsystemd is needed for USE_SYSTEMD")
+    endif ()
+endif ()
+
 # https://bugs.webkit.org/show_bug.cgi?id=182247
 if (ENABLED_COMPILER_SANITIZERS)
     set(ENABLE_INTROSPECTION OFF)
index 05531cf..95c383a 100644 (file)
@@ -74,6 +74,7 @@ WEBKIT_OPTION_DEFINE(ENABLE_GTKDOC "Whether or not to use generate gtkdoc." PUBL
 WEBKIT_OPTION_DEFINE(USE_OPENJPEG "Whether to enable support for JPEG2000 images." PUBLIC ON)
 WEBKIT_OPTION_DEFINE(USE_WOFF2 "Whether to enable support for WOFF2 Web Fonts." PUBLIC ON)
 WEBKIT_OPTION_DEFINE(ENABLE_WPE_QT_API "Whether to enable support for the Qt5/QML plugin" PUBLIC OFF)
+WEBKIT_OPTION_DEFINE(USE_SYSTEMD "Whether to enable journald logging" PUBLIC ON)
 
 # Private options specific to the WPE port.
 WEBKIT_OPTION_DEFINE(USE_GSTREAMER_HOLEPUNCH "Whether to enable GStreamer holepunch" PRIVATE OFF)
@@ -172,11 +173,22 @@ if (ENABLE_WPE_QT_API OR USE_WPE_VIDEO_PLANE_DISPLAY_DMABUF)
     find_package(WPEBackend_fdo 1.5.0 REQUIRED)
 endif ()
 
+
 if (ENABLE_WEBXR)
     find_package(OpenXR 1.0)
     SET_AND_EXPOSE_TO_BUILD(USE_OPENXR ${OpenXR_FOUND})
 endif ()
 
+if (USE_SYSTEMD)
+    find_package(Systemd)
+    if (Systemd_FOUND)
+        message(STATUS "Release logs will be sent to the Systemd journal")
+        SET_AND_EXPOSE_TO_BUILD(USE_JOURNALD TRUE)
+    else ()
+        message(FATAL_ERROR "libsystemd is needed for USE_SYSTEMD")
+    endif ()
+endif ()
+
 add_definitions(-DBUILDING_WPE__=1)
 add_definitions(-DGETTEXT_PACKAGE="WPE")
 add_definitions(-DJSC_GLIB_API_ENABLED)
index 6fd566f..ba62273 100755 (executable)
@@ -133,6 +133,7 @@ function installDependenciesWithApt {
         libsoup2.4-dev \
         libsqlite3-dev \
         libsrtp2-dev \
+        libsystemd-dev \
         libtasn1-6-dev \
         libtheora-dev \
         libtool \
@@ -307,6 +308,7 @@ function installDependenciesWithPacman {
         libsecret \
         libsoup \
         libsrtp \
+        libsystemd \
         sqlite \
         libtasn1 \
         libtheora \
@@ -467,6 +469,7 @@ function installDependenciesWithDnf {
         libsecret-devel \
         libsoup-devel \
         libsrtp-devel \
+        libsystemd-devel \
         libtasn1-devel \
         libtheora-devel \
         libv4l-devel \
index ca1cd3f..e428cd2 100755 (executable)
@@ -81,6 +81,7 @@ function installDependenciesWithApt {
         $(aptIfElse libpng-dev libpng12-dev) \
         libseccomp-dev \
         libsqlite3-dev \
+        libsystemd-dev \
         libtasn1-6-dev \
         libtool \
         libwebp-dev \
@@ -192,6 +193,7 @@ function installDependenciesWithPacman {
         ruby
         sed \
         sqlite \
+        libsystemd \
         texinfo \
         which \
         zlib \
@@ -291,6 +293,7 @@ function installDependenciesWithDnf {
         libjpeg-turbo-devel \
         libpng-devel \
         libseccomp-devel \
+        libsystemd-devel \
         libtasn1-devel \
         libtool \
         libwebp-devel \