Add a "supportedConfiguration" dictionary to MediaCapabilitiesDecodingInfo and MediaC...
[WebKit-https.git] / Source / WebCore / platform / Logging.cpp
index 0003b78..aec5866 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "config.h"
 #include "Logging.h"
+#include "LogInitialization.h"
 
 #include <wtf/StdLibExtras.h>
 #include <wtf/text/CString.h>
 
 #if PLATFORM(COCOA)
 #include <notify.h>
+#include <wtf/BlockPtr.h>
 #endif
 
-#if !LOG_DISABLED
-
 namespace WebCore {
 
-#define DEFINE_LOG_CHANNEL(name) \
-    WTFLogChannel JOIN_LOG_CHANNEL_WITH_PREFIX(LOG_CHANNEL_PREFIX, name) = { WTFLogChannelOff, #name };
-WEBCORE_LOG_CHANNELS(DEFINE_LOG_CHANNEL)
+#if !LOG_DISABLED || !RELEASE_LOG_DISABLED
+
+#define DEFINE_WEBCORE_LOG_CHANNEL(name) DEFINE_LOG_CHANNEL(name, LOG_CHANNEL_WEBKIT_SUBSYSTEM)
+WEBCORE_LOG_CHANNELS(DEFINE_WEBCORE_LOG_CHANNEL)
 
-#define LOG_CHANNEL_ADDRESS(name)  &JOIN_LOG_CHANNEL_WITH_PREFIX(LOG_CHANNEL_PREFIX, name),
-WTFLogChannel* logChannels[] = {
+static WTFLogChannel* logChannels[] = {
     WEBCORE_LOG_CHANNELS(LOG_CHANNEL_ADDRESS)
 };
 
-size_t logChannelCount = WTF_ARRAY_LENGTH(logChannels);
+static const size_t logChannelCount = WTF_ARRAY_LENGTH(logChannels);
 
 bool isLogChannelEnabled(const String& name)
 {
@@ -57,36 +57,41 @@ bool isLogChannelEnabled(const String& name)
     return channel->state != WTFLogChannelOff;
 }
 
-void initializeLoggingChannelsIfNecessary()
+static bool logChannelsNeedInitialization = true;
+
+void setLogChannelToAccumulate(const String& name)
 {
-    static bool haveInitializedLoggingChannels = false;
-    if (haveInitializedLoggingChannels)
+    WTFLogChannel* channel = WTFLogChannelByName(logChannels, logChannelCount, name.utf8().data());
+    if (!channel)
         return;
-    haveInitializedLoggingChannels = true;
 
-    WTFInitializeLogChannelStatesFromString(logChannels, logChannelCount, logLevelString().utf8().data());
+    channel->state = WTFLogChannelOnWithAccumulation;
+    logChannelsNeedInitialization = true;
 }
 
-#ifndef NDEBUG
-void registerNotifyCallback(const String& notifyID, std::function<void()> callback)
+void initializeLogChannelsIfNecessary(Optional<String> logChannelString)
 {
-#if PLATFORM(COCOA)
-    int token;
-    notify_register_dispatch(notifyID.utf8().data(), &token, dispatch_get_main_queue(), ^(int) {
-        callback();
-    });
-#else
-    UNUSED_PARAM(notifyID);
-    UNUSED_PARAM(callback);
-#endif
+    if (!logChannelsNeedInitialization && !logChannelString)
+        return;
+
+    logChannelsNeedInitialization = false;
+
+    String enabledChannelsString = logChannelString ? logChannelString.value() : logLevelString();
+    WTFInitializeLogChannelStatesFromString(logChannels, logChannelCount, enabledChannelsString.utf8().data());
 }
-#endif
 
-void logFunctionResult(WTFLogChannel* channel, std::function<const char*()> function)
+WTFLogChannel* getLogChannel(const String& name)
 {
-    WTFLog(channel, "%s", function());
+    return WTFLogChannelByName(logChannels, logChannelCount, name.utf8().data());
 }
 
-} // namespace WebCore
+#else
 
-#endif // !LOG_DISABLED
+WTFLogChannel* getLogChannel(const String&)
+{
+    return nullptr;
+}
+
+#endif // !LOG_DISABLED || !RELEASE_LOG_DISABLED
+
+} // namespace WebCore