Logging macros are sensitive to pal/Logging.h vs Logging.h include order
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Jun 2018 18:20:31 +0000 (18:20 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Jun 2018 18:20:31 +0000 (18:20 +0000)
https://bugs.webkit.org/show_bug.cgi?id=185893

Reviewed by Zalan Bujtas.

Remove unused functionality from pal/Logging code until we need it. Primarily this removes the
#define LOG_CHANNEL_PREFIX from pal/Logging.h, which caused include-order problems with unified sources.

Future work should move shared logging code up to WTF (or into PAL).

* PAL.xcodeproj/project.pbxproj:
* pal/CMakeLists.txt:
* pal/LogInitialization.h: Removed.
* pal/Logging.cpp:
(PAL::isLogChannelEnabled): Deleted.
(PAL::setLogChannelToAccumulate): Deleted.
(PAL::initializeLogChannelsIfNecessary): Deleted.
* pal/Logging.h:
* pal/cocoa/LoggingCocoa.mm: Removed.

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

Source/WebCore/PAL/ChangeLog
Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj
Source/WebCore/PAL/pal/CMakeLists.txt
Source/WebCore/PAL/pal/LogInitialization.h [deleted file]
Source/WebCore/PAL/pal/Logging.cpp
Source/WebCore/PAL/pal/Logging.h
Source/WebCore/PAL/pal/cocoa/LoggingCocoa.mm [deleted file]

index 20fd535..0b887c0 100644 (file)
@@ -1,3 +1,25 @@
+2018-06-06  Simon Fraser  <simon.fraser@apple.com>
+
+        Logging macros are sensitive to pal/Logging.h vs Logging.h include order
+        https://bugs.webkit.org/show_bug.cgi?id=185893
+
+        Reviewed by Zalan Bujtas.
+        
+        Remove unused functionality from pal/Logging code until we need it. Primarily this removes the
+        #define LOG_CHANNEL_PREFIX from pal/Logging.h, which caused include-order problems with unified sources.
+        
+        Future work should move shared logging code up to WTF (or into PAL).
+
+        * PAL.xcodeproj/project.pbxproj:
+        * pal/CMakeLists.txt:
+        * pal/LogInitialization.h: Removed.
+        * pal/Logging.cpp:
+        (PAL::isLogChannelEnabled): Deleted.
+        (PAL::setLogChannelToAccumulate): Deleted.
+        (PAL::initializeLogChannelsIfNecessary): Deleted.
+        * pal/Logging.h:
+        * pal/cocoa/LoggingCocoa.mm: Removed.
+
 2018-06-05  Brent Fulgham  <bfulgham@apple.com>
 
         Adjust compile and runtime flags to match shippable state of features
index 8109bf5..e43e1b8 100644 (file)
                1C09D0581E31C57E00725F18 /* config.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C09D0571E31C57E00725F18 /* config.h */; };
                1C4876D81F8D7F4E00CCEEBD /* Logging.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C4876D61F8D7F4E00CCEEBD /* Logging.cpp */; };
                1C4876D91F8D7F4E00CCEEBD /* Logging.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C4876D71F8D7F4E00CCEEBD /* Logging.h */; };
-               1C4876E01F8D837500CCEEBD /* LoggingCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1C4876DF1F8D837500CCEEBD /* LoggingCocoa.mm */; };
                2D02E93C2056FAA700A13797 /* AudioToolboxSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D02E93B2056FAA700A13797 /* AudioToolboxSPI.h */; };
                31308B1420A21705003FB929 /* SystemPreviewSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 31308B1320A21705003FB929 /* SystemPreviewSPI.h */; };
                570AB8F120AE2E8D00B8BE87 /* SecKeyProxySPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 570AB8F020AE2E8D00B8BE87 /* SecKeyProxySPI.h */; };
                1C4876D61F8D7F4E00CCEEBD /* Logging.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Logging.cpp; sourceTree = "<group>"; };
                1C4876D71F8D7F4E00CCEEBD /* Logging.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Logging.h; sourceTree = "<group>"; };
                1C4876DC1F8D7FC600CCEEBD /* LogMacros.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LogMacros.h; sourceTree = "<group>"; };
-               1C4876DD1F8D812B00CCEEBD /* LogInitialization.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LogInitialization.h; sourceTree = "<group>"; };
-               1C4876DF1F8D837500CCEEBD /* LoggingCocoa.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = LoggingCocoa.mm; sourceTree = "<group>"; };
                1C67CEA11E32EDA800F80F2E /* FeatureDefines.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = FeatureDefines.xcconfig; sourceTree = "<group>"; };
                1C67CEA21E32EE2600F80F2E /* Version.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Version.xcconfig; sourceTree = "<group>"; };
                2D02E93B2056FAA700A13797 /* AudioToolboxSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioToolboxSPI.h; sourceTree = "<group>"; };
                                A39DE74D1F7C443C007BCB00 /* HysteresisActivity.h */,
                                1C4876D61F8D7F4E00CCEEBD /* Logging.cpp */,
                                1C4876D71F8D7F4E00CCEEBD /* Logging.h */,
-                               1C4876DD1F8D812B00CCEEBD /* LogInitialization.h */,
                                1C4876DC1F8D7FC600CCEEBD /* LogMacros.h */,
                                A3C66CDA1F462D6A009E6EE9 /* SessionID.cpp */,
                                A3C66CDB1F462D6A009E6EE9 /* SessionID.h */,
                        isa = PBXGroup;
                        children = (
                                F44291661FA52705002CC93E /* FileSizeFormatterCocoa.mm */,
-                               1C4876DF1F8D837500CCEEBD /* LoggingCocoa.mm */,
                        );
                        path = cocoa;
                        sourceTree = "<group>";
                                A30D41221F0DD0EA00B71954 /* KillRing.cpp in Sources */,
                                A30D41251F0DD12D00B71954 /* KillRingMac.mm in Sources */,
                                1C4876D81F8D7F4E00CCEEBD /* Logging.cpp in Sources */,
-                               1C4876E01F8D837500CCEEBD /* LoggingCocoa.mm in Sources */,
                                0CF99CA41F736375007EE793 /* MediaTimeAVFoundation.cpp in Sources */,
                                A1175B4F1F6B337300C4B9F0 /* PopupMenu.mm in Sources */,
                                A3C66CDC1F462D6A009E6EE9 /* SessionID.cpp in Sources */,
index aebe481..2f6e8f2 100644 (file)
@@ -2,7 +2,6 @@ set(PAL_PUBLIC_HEADERS
     ExportMacros.h
     FileSizeFormatter.h
     HysteresisActivity.h
-    LogInitialization.h
     LogMacros.h
     Logging.h
     SessionID.h
diff --git a/Source/WebCore/PAL/pal/LogInitialization.h b/Source/WebCore/PAL/pal/LogInitialization.h
deleted file mode 100644 (file)
index 57fdd68..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2003, 2006, 2013, 2015, 2016, 2017 Apple Inc.  All rights reserved.
- *
- * 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 APPLE INC. ``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 APPLE INC. OR
- * 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.
- */
-
-#pragma once
-
-#include <wtf/Assertions.h>
-#include <wtf/Forward.h>
-#include <wtf/Optional.h>
-#include <wtf/text/WTFString.h>
-
-namespace PAL {
-
-#if !LOG_DISABLED || !RELEASE_LOG_DISABLED
-
-String logLevelString();
-bool isLogChannelEnabled(const String& name);
-PAL_EXPORT void setLogChannelToAccumulate(const String& name);
-PAL_EXPORT void initializeLogChannelsIfNecessary(std::optional<String> = std::nullopt);
-
-#endif // !LOG_DISABLED || !RELEASE_LOG_DISABLED
-
-} // namespace WebCore
index ac85b6d..e62548d 100644 (file)
 #include "config.h"
 #include "Logging.h"
 
-#include "LogInitialization.h"
-
-#include <wtf/StdLibExtras.h>
-#include <wtf/text/CString.h>
 #include <wtf/text/WTFString.h>
 
 #if PLATFORM(COCOA)
 
 namespace PAL {
 
-#if !LOG_DISABLED || !RELEASE_LOG_DISABLED
-
-#define DEFINE_PAL_LOG_CHANNEL(name) DEFINE_LOG_CHANNEL(name, LOG_CHANNEL_WEBKIT_SUBSYSTEM)
-PAL_LOG_CHANNELS(DEFINE_PAL_LOG_CHANNEL)
-
-static WTFLogChannel* logChannels[] = {
-    PAL_LOG_CHANNELS(LOG_CHANNEL_ADDRESS)
-};
-
-static const size_t logChannelCount = WTF_ARRAY_LENGTH(logChannels);
-
-bool isLogChannelEnabled(const String& name)
-{
-    WTFLogChannel* channel = WTFLogChannelByName(logChannels, logChannelCount, name.utf8().data());
-    if (!channel)
-        return false;
-    return channel->state != WTFLogChannelOff;
-}
-
-static bool logChannelsNeedInitialization = true;
-
-void setLogChannelToAccumulate(const String& name)
-{
-    WTFLogChannel* channel = WTFLogChannelByName(logChannels, logChannelCount, name.utf8().data());
-    if (!channel)
-        return;
-
-    channel->state = WTFLogChannelOnWithAccumulation;
-    logChannelsNeedInitialization = true;
-}
-
-void initializeLogChannelsIfNecessary(std::optional<String> logChannelString)
-{
-    if (!logChannelsNeedInitialization && !logChannelString)
-        return;
-
-    logChannelsNeedInitialization = false;
-
-    String enabledChannelsString = logChannelString ? logChannelString.value() : logLevelString();
-    WTFInitializeLogChannelStatesFromString(logChannels, logChannelCount, enabledChannelsString.utf8().data());
-}
-
-#endif // !LOG_DISABLED || !RELEASE_LOG_DISABLED
-
 void registerNotifyCallback(const String& notifyID, WTF::Function<void()>&& callback)
 {
 #if PLATFORM(COCOA)
@@ -97,4 +49,3 @@ void registerNotifyCallback(const String& notifyID, WTF::Function<void()>&& call
 }
 
 } // namespace WebCore
-
index 031399c..6caaedb 100644 (file)
 
 #pragma once
 
-#include "LogMacros.h"
-#include <wtf/Assertions.h>
 #include <wtf/Forward.h>
 
 namespace PAL {
 
-#if !LOG_DISABLED || !RELEASE_LOG_DISABLED
-
-#ifndef LOG_CHANNEL_PREFIX
-#define LOG_CHANNEL_PREFIX PALLog
-#endif
-
-#define PAL_LOG_CHANNELS(M) \
-    M(Network) \
-
-PAL_LOG_CHANNELS(DECLARE_LOG_CHANNEL)
-
-String logLevelString();
-bool isLogChannelEnabled(const String& name);
-PAL_EXPORT void setLogChannelToAccumulate(const String& name);
-
-#endif // !LOG_DISABLED || !RELEASE_LOG_DISABLED
-
 PAL_EXPORT void registerNotifyCallback(const String&, WTF::Function<void()>&&);
 
 } // namespace PAL
diff --git a/Source/WebCore/PAL/pal/cocoa/LoggingCocoa.mm b/Source/WebCore/PAL/pal/cocoa/LoggingCocoa.mm
deleted file mode 100644 (file)
index 2cdcea2..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2003, 2006, 2013 Apple Inc.  All rights reserved.
- *
- * 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 APPLE INC. ``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 APPLE INC. OR
- * 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.
- */
-
-#include "config.h"
-#include "Logging.h"
-
-#include <wtf/text/WTFString.h>
-
-#if !LOG_DISABLED || !RELEASE_LOG_DISABLED
-
-namespace PAL {
-
-String logLevelString()
-{
-#if !LOG_DISABLED
-    static NSString * const defaultsDomain = @"PALLogging";
-    return [[NSUserDefaults standardUserDefaults] stringForKey:defaultsDomain];
-#else
-    return String();
-#endif
-}
-
-}
-
-#endif // !LOG_DISABLED || !RELEASE_LOG_DISABLED
-