haikuwebkit/Source/WebCore/platform/LogInitialization.h

43 lines
1.7 KiB
C
Raw Permalink Normal View History

Allow LOG macros to be used outside the namespace, and other logging cleanup https://bugs.webkit.org/show_bug.cgi?id=160216 Reviewed by Anders Carlsson. Source/WebCore: Fix some issues with the LOG macros. First, they were not usable outside the WebKit namespace in WebKit2 code. Fix by moving its log channels outside of the namespace (they are protected by a unique prefix anyway). Second, allow LOG_WITH_STREAM to be used in WebKit2 by moving that and a helper macro into LogMacros.h, which is exported from WebCore as a private header. Third, split the Logging.h header into two. Logging.h remains for framework-internal log channels and log macros. Add LogInitialization.h which is external, and used to initialize the channels. Finally unify "initializeLogChannels" and "initializeLoggingChannels" terminology everywhere. * WebCore.xcodeproj/project.pbxproj: * platform/LogInitialization.h: Added. * platform/LogMacros.h: Added. * platform/Logging.cpp: (WebCore::initializeLogChannelsIfNecessary): (WebCore::initializeLoggingChannelsIfNecessary): Deleted. * platform/Logging.h: * testing/js/WebCoreTestSupport.cpp: (WebCoreTestSupport::initializeLogChannelsIfNecessary): (WebCoreTestSupport::initializeLoggingChannelsIfNecessary): Deleted. * testing/js/WebCoreTestSupport.h: Source/WebKit: Fix some issues with the LOG macros. First, they were not usable outside the WebKit namespace in WebKit2 code. Fix by moving its log channels outside of the namespace (they are protected by a unique prefix anyway). Second, allow LOG_WITH_STREAM to be used in WebKit2 by moving that and a helper macro into LogMacros.h, which is exported from WebCore as a private header. Third, split the Logging.h header into two. Logging.h remains for framework-internal log channels and log macros. Add LogInitialization.h which is external, and used to initialize the channels. Finally unify "initializeLogChannels" and "initializeLoggingChannels" terminology everywhere. * WebCoreSupport/WebResourceLoadScheduler.cpp: Source/WebKit/mac: Fix some issues with the LOG macros. First, they were not usable outside the WebKit namespace in WebKit2 code. Fix by moving its log channels outside of the namespace (they are protected by a unique prefix anyway). Second, allow LOG_WITH_STREAM to be used in WebKit2 by moving that and a helper macro into LogMacros.h, which is exported from WebCore as a private header. Third, split the Logging.h header into two. Logging.h remains for framework-internal log channels and log macros. Add LogInitialization.h which is external, and used to initialize the channels. Finally unify "initializeLogChannels" and "initializeLoggingChannels" terminology everywhere. * Misc/WebKitLogging.h: * Misc/WebKitLogging.m: * WebView/WebView.mm: (-[WebView _commonInitializationWithFrameName:groupName:]): Source/WebKit/win: Fix some issues with the LOG macros. First, they were not usable outside the WebKit namespace in WebKit2 code. Fix by moving its log channels outside of the namespace (they are protected by a unique prefix anyway). Second, allow LOG_WITH_STREAM to be used in WebKit2 by moving that and a helper macro into LogMacros.h, which is exported from WebCore as a private header. Third, split the Logging.h header into two. Logging.h remains for framework-internal log channels and log macros. Add LogInitialization.h which is external, and used to initialize the channels. Finally unify "initializeLogChannels" and "initializeLoggingChannels" terminology everywhere. * WebKitLogging.cpp: * WebKitLogging.h: * WebView.cpp: (WebView::initWithFrame): Source/WebKit2: Fix some issues with the LOG macros. First, they were not usable outside the WebKit namespace in WebKit2 code. Fix by moving its log channels outside of the namespace (they are protected by a unique prefix anyway). Second, allow LOG_WITH_STREAM to be used in WebKit2 by moving that and a helper macro into LogMacros.h, which is exported from WebCore as a private header. Third, split the Logging.h header into two. Logging.h remains for framework-internal log channels and log macros. Add LogInitialization.h which is external, and used to initialize the channels. Finally unify "initializeLogChannels" and "initializeLoggingChannels" terminology everywhere. * NetworkProcess/NetworkProcess.cpp: * Platform/LogInitialization.h: Copied from Source/WebKit2/Platform/foundation/LoggingFoundation.mm. * Platform/Logging.cpp: (WebKit::initializeLogChannelsIfNecessary): * Platform/Logging.h: * Platform/foundation/LoggingFoundation.mm: * Shared/WebKit2Initialize.cpp: (WebKit::InitializeWebKit2): * UIProcess/API/Cocoa/WKWebView.mm: (-[WKWebView _updateContentRectsWithState:]): (-[WKWebView _navigationGestureDidBegin]): * UIProcess/WebProcessPool.cpp: (WebKit::m_hiddenPageThrottlingTimer): * WebKit2.xcodeproj/project.pbxproj: Tools: initializeLoggingChannelsIfNecessary -> initializeLogChannelsIfNecessary * DumpRenderTree/TestRunner.cpp: * DumpRenderTree/mac/DumpRenderTree.mm: (resetWebViewToConsistentStateBeforeTesting): Canonical link: https://commits.webkit.org/178378@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@203749 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-07-26 23:30:01 +00:00
/*
Deduplicate logging channel algorithms https://bugs.webkit.org/show_bug.cgi?id=228809 Reviewed by Fujii Hironori. Source/WebCore: No new tests because there is no behavior change. * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * accessibility/AXLogger.cpp: * inspector/agents/page/PageConsoleAgent.cpp: * page/Page.cpp: * platform/LogInitialization.cpp: Copied from Source/WebCore/platform/LogInitialization.h. (WebCore::logChannels): (WebCore::getLogChannel): * platform/LogInitialization.h: * platform/Logging.cpp: (WebCore::isLogChannelEnabled): Deleted. (WebCore::setLogChannelToAccumulate): Deleted. (WebCore::clearAllLogChannelsToAccumulate): Deleted. (WebCore::initializeLogChannelsIfNecessary): Deleted. (WebCore::getLogChannel): Deleted. * platform/Logging.h: * testing/js/WebCoreTestSupport.cpp: (WebCoreTestSupport::setLogChannelToAccumulate): (WebCoreTestSupport::clearAllLogChannelsToAccumulate): (WebCoreTestSupport::initializeLogChannelsIfNecessary): Source/WebKit: * GPUProcess/GPUConnectionToWebProcess.cpp: * GPUProcess/GPUProcess.cpp: (WebKit::GPUProcess::initializeGPUProcess): * Platform/LogInitialization.cpp: Copied from Source/WebKit/Shared/WebKit2Initialize.cpp. (WebKit::logChannels): (WebKit::getLogChannel): * Platform/LogInitialization.h: * Platform/Logging.cpp: (WebKit::initializeLogChannelsIfNecessary): Deleted. (WebKit::getLogChannel): Deleted. * Platform/Logging.h: * Shared/AuxiliaryProcess.cpp: (WebKit::AuxiliaryProcess::initialize): * Shared/WebKit2Initialize.cpp: (WebKit::InitializeWebKit2): * Sources.txt: * UIProcess/WebPageProxy.cpp: * UIProcess/WebProcessPool.cpp: * WebKit.xcodeproj/project.pbxproj: * WebProcess/cocoa/WebProcessCocoa.mm: (WebKit::WebProcess::platformInitializeWebProcess): Source/WebKitLegacy: * WebKitLegacy.xcodeproj/project.pbxproj: Source/WebKitLegacy/mac: * Misc/WebKitLogInitialization.h: Copied from Source/WebKit/Platform/LogInitialization.h. * Misc/WebKitLogInitialization.mm: Copied from Source/WebKitLegacy/mac/Misc/WebKitLogging.m. (WebKit::logChannels): (ReportDiscardedDelegateException): * Misc/WebKitLogging.h: * Misc/WebKitLogging.m: (ReportDiscardedDelegateException): Deleted. * WebCoreSupport/WebDragClient.mm: * WebView/WebDelegateImplementationCaching.mm: * WebView/WebView.mm: (-[WebView _commonInitializationWithFrameName:groupName:]): Source/WTF: The current infrastructure (before this patch) had the following duplicated for each framework: - A .cpp file declared the list of logging channels for that framework - The .cpp file also had algorithms to search, modify, and initialize these logging channels Each framework's .cpp file had duplicate algorithms. (The initialization algorithm was even duplicated 3 times!) Because the algorithms directly name their specific list of logging channels, a naive deduplication would have had to add new parameters to these algorithms to pass in the appropriate framework's list. That's fine, but this is exactly the sort of thing classes were designed for - classes are an association of algorithms and data. The algorithms are shared but the data isn't, which really just means we should have 3 instances of a shared class - one for the 3 sets of data. So, this patch creates the LogChannels class which contains the deduplicated algorithms, and each framework has a NeverDestroyed singleton instance of that class. There is a single virtual method in the class, so the appropriate "default write" variable can be queried for each framework. The instances cannot be declared in the Logging.h files in the frameworks, because certain WebKit2 files want to initialize all 3 instances of LogChannels, but you can't #include multiple Logging.h files at the same time because their LOG_CHANNEL_PREFIX #defines will collide with each other. Luckily, LogInitialization.h files exist exactly to solve this purpose, so that's where the LogChannels instances are declared in. After this change, the Logging.h files are just for the declarations of the logging channels themselves, and the LogInitialization.h files are for the LogChannels instances which contain the searching/modifying/initializing algorithms on the list of logging channels. If you just want to LOG(...) something, #include the relevant Logging.h file, and if you want to search/modify/initialize across the entire list of channels, then #include the relevant LogInitialization.h file. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/LogChannels.cpp: Copied from Source/WebCore/platform/Logging.cpp. (WTF::LogChannels::isLogChannelEnabled): (WTF::LogChannels::setLogChannelToAccumulate): (WTF::LogChannels::clearAllLogChannelsToAccumulate): (WTF::LogChannels::initializeLogChannelsIfNecessary): (WTF::LogChannels::getLogChannel): * wtf/LogChannels.h: Copied from Source/WebCore/platform/LogInitialization.h. Canonical link: https://commits.webkit.org/240343@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280758 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-07 18:50:12 +00:00
* Copyright (C) 2010-2021 Apple Inc. All rights reserved.
Allow LOG macros to be used outside the namespace, and other logging cleanup https://bugs.webkit.org/show_bug.cgi?id=160216 Reviewed by Anders Carlsson. Source/WebCore: Fix some issues with the LOG macros. First, they were not usable outside the WebKit namespace in WebKit2 code. Fix by moving its log channels outside of the namespace (they are protected by a unique prefix anyway). Second, allow LOG_WITH_STREAM to be used in WebKit2 by moving that and a helper macro into LogMacros.h, which is exported from WebCore as a private header. Third, split the Logging.h header into two. Logging.h remains for framework-internal log channels and log macros. Add LogInitialization.h which is external, and used to initialize the channels. Finally unify "initializeLogChannels" and "initializeLoggingChannels" terminology everywhere. * WebCore.xcodeproj/project.pbxproj: * platform/LogInitialization.h: Added. * platform/LogMacros.h: Added. * platform/Logging.cpp: (WebCore::initializeLogChannelsIfNecessary): (WebCore::initializeLoggingChannelsIfNecessary): Deleted. * platform/Logging.h: * testing/js/WebCoreTestSupport.cpp: (WebCoreTestSupport::initializeLogChannelsIfNecessary): (WebCoreTestSupport::initializeLoggingChannelsIfNecessary): Deleted. * testing/js/WebCoreTestSupport.h: Source/WebKit: Fix some issues with the LOG macros. First, they were not usable outside the WebKit namespace in WebKit2 code. Fix by moving its log channels outside of the namespace (they are protected by a unique prefix anyway). Second, allow LOG_WITH_STREAM to be used in WebKit2 by moving that and a helper macro into LogMacros.h, which is exported from WebCore as a private header. Third, split the Logging.h header into two. Logging.h remains for framework-internal log channels and log macros. Add LogInitialization.h which is external, and used to initialize the channels. Finally unify "initializeLogChannels" and "initializeLoggingChannels" terminology everywhere. * WebCoreSupport/WebResourceLoadScheduler.cpp: Source/WebKit/mac: Fix some issues with the LOG macros. First, they were not usable outside the WebKit namespace in WebKit2 code. Fix by moving its log channels outside of the namespace (they are protected by a unique prefix anyway). Second, allow LOG_WITH_STREAM to be used in WebKit2 by moving that and a helper macro into LogMacros.h, which is exported from WebCore as a private header. Third, split the Logging.h header into two. Logging.h remains for framework-internal log channels and log macros. Add LogInitialization.h which is external, and used to initialize the channels. Finally unify "initializeLogChannels" and "initializeLoggingChannels" terminology everywhere. * Misc/WebKitLogging.h: * Misc/WebKitLogging.m: * WebView/WebView.mm: (-[WebView _commonInitializationWithFrameName:groupName:]): Source/WebKit/win: Fix some issues with the LOG macros. First, they were not usable outside the WebKit namespace in WebKit2 code. Fix by moving its log channels outside of the namespace (they are protected by a unique prefix anyway). Second, allow LOG_WITH_STREAM to be used in WebKit2 by moving that and a helper macro into LogMacros.h, which is exported from WebCore as a private header. Third, split the Logging.h header into two. Logging.h remains for framework-internal log channels and log macros. Add LogInitialization.h which is external, and used to initialize the channels. Finally unify "initializeLogChannels" and "initializeLoggingChannels" terminology everywhere. * WebKitLogging.cpp: * WebKitLogging.h: * WebView.cpp: (WebView::initWithFrame): Source/WebKit2: Fix some issues with the LOG macros. First, they were not usable outside the WebKit namespace in WebKit2 code. Fix by moving its log channels outside of the namespace (they are protected by a unique prefix anyway). Second, allow LOG_WITH_STREAM to be used in WebKit2 by moving that and a helper macro into LogMacros.h, which is exported from WebCore as a private header. Third, split the Logging.h header into two. Logging.h remains for framework-internal log channels and log macros. Add LogInitialization.h which is external, and used to initialize the channels. Finally unify "initializeLogChannels" and "initializeLoggingChannels" terminology everywhere. * NetworkProcess/NetworkProcess.cpp: * Platform/LogInitialization.h: Copied from Source/WebKit2/Platform/foundation/LoggingFoundation.mm. * Platform/Logging.cpp: (WebKit::initializeLogChannelsIfNecessary): * Platform/Logging.h: * Platform/foundation/LoggingFoundation.mm: * Shared/WebKit2Initialize.cpp: (WebKit::InitializeWebKit2): * UIProcess/API/Cocoa/WKWebView.mm: (-[WKWebView _updateContentRectsWithState:]): (-[WKWebView _navigationGestureDidBegin]): * UIProcess/WebProcessPool.cpp: (WebKit::m_hiddenPageThrottlingTimer): * WebKit2.xcodeproj/project.pbxproj: Tools: initializeLoggingChannelsIfNecessary -> initializeLogChannelsIfNecessary * DumpRenderTree/TestRunner.cpp: * DumpRenderTree/mac/DumpRenderTree.mm: (resetWebViewToConsistentStateBeforeTesting): Canonical link: https://commits.webkit.org/178378@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@203749 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-07-26 23:30:01 +00:00
*
* 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
Deduplicate logging channel algorithms https://bugs.webkit.org/show_bug.cgi?id=228809 Reviewed by Fujii Hironori. Source/WebCore: No new tests because there is no behavior change. * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * accessibility/AXLogger.cpp: * inspector/agents/page/PageConsoleAgent.cpp: * page/Page.cpp: * platform/LogInitialization.cpp: Copied from Source/WebCore/platform/LogInitialization.h. (WebCore::logChannels): (WebCore::getLogChannel): * platform/LogInitialization.h: * platform/Logging.cpp: (WebCore::isLogChannelEnabled): Deleted. (WebCore::setLogChannelToAccumulate): Deleted. (WebCore::clearAllLogChannelsToAccumulate): Deleted. (WebCore::initializeLogChannelsIfNecessary): Deleted. (WebCore::getLogChannel): Deleted. * platform/Logging.h: * testing/js/WebCoreTestSupport.cpp: (WebCoreTestSupport::setLogChannelToAccumulate): (WebCoreTestSupport::clearAllLogChannelsToAccumulate): (WebCoreTestSupport::initializeLogChannelsIfNecessary): Source/WebKit: * GPUProcess/GPUConnectionToWebProcess.cpp: * GPUProcess/GPUProcess.cpp: (WebKit::GPUProcess::initializeGPUProcess): * Platform/LogInitialization.cpp: Copied from Source/WebKit/Shared/WebKit2Initialize.cpp. (WebKit::logChannels): (WebKit::getLogChannel): * Platform/LogInitialization.h: * Platform/Logging.cpp: (WebKit::initializeLogChannelsIfNecessary): Deleted. (WebKit::getLogChannel): Deleted. * Platform/Logging.h: * Shared/AuxiliaryProcess.cpp: (WebKit::AuxiliaryProcess::initialize): * Shared/WebKit2Initialize.cpp: (WebKit::InitializeWebKit2): * Sources.txt: * UIProcess/WebPageProxy.cpp: * UIProcess/WebProcessPool.cpp: * WebKit.xcodeproj/project.pbxproj: * WebProcess/cocoa/WebProcessCocoa.mm: (WebKit::WebProcess::platformInitializeWebProcess): Source/WebKitLegacy: * WebKitLegacy.xcodeproj/project.pbxproj: Source/WebKitLegacy/mac: * Misc/WebKitLogInitialization.h: Copied from Source/WebKit/Platform/LogInitialization.h. * Misc/WebKitLogInitialization.mm: Copied from Source/WebKitLegacy/mac/Misc/WebKitLogging.m. (WebKit::logChannels): (ReportDiscardedDelegateException): * Misc/WebKitLogging.h: * Misc/WebKitLogging.m: (ReportDiscardedDelegateException): Deleted. * WebCoreSupport/WebDragClient.mm: * WebView/WebDelegateImplementationCaching.mm: * WebView/WebView.mm: (-[WebView _commonInitializationWithFrameName:groupName:]): Source/WTF: The current infrastructure (before this patch) had the following duplicated for each framework: - A .cpp file declared the list of logging channels for that framework - The .cpp file also had algorithms to search, modify, and initialize these logging channels Each framework's .cpp file had duplicate algorithms. (The initialization algorithm was even duplicated 3 times!) Because the algorithms directly name their specific list of logging channels, a naive deduplication would have had to add new parameters to these algorithms to pass in the appropriate framework's list. That's fine, but this is exactly the sort of thing classes were designed for - classes are an association of algorithms and data. The algorithms are shared but the data isn't, which really just means we should have 3 instances of a shared class - one for the 3 sets of data. So, this patch creates the LogChannels class which contains the deduplicated algorithms, and each framework has a NeverDestroyed singleton instance of that class. There is a single virtual method in the class, so the appropriate "default write" variable can be queried for each framework. The instances cannot be declared in the Logging.h files in the frameworks, because certain WebKit2 files want to initialize all 3 instances of LogChannels, but you can't #include multiple Logging.h files at the same time because their LOG_CHANNEL_PREFIX #defines will collide with each other. Luckily, LogInitialization.h files exist exactly to solve this purpose, so that's where the LogChannels instances are declared in. After this change, the Logging.h files are just for the declarations of the logging channels themselves, and the LogInitialization.h files are for the LogChannels instances which contain the searching/modifying/initializing algorithms on the list of logging channels. If you just want to LOG(...) something, #include the relevant Logging.h file, and if you want to search/modify/initialize across the entire list of channels, then #include the relevant LogInitialization.h file. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/LogChannels.cpp: Copied from Source/WebCore/platform/Logging.cpp. (WTF::LogChannels::isLogChannelEnabled): (WTF::LogChannels::setLogChannelToAccumulate): (WTF::LogChannels::clearAllLogChannelsToAccumulate): (WTF::LogChannels::initializeLogChannelsIfNecessary): (WTF::LogChannels::getLogChannel): * wtf/LogChannels.h: Copied from Source/WebCore/platform/LogInitialization.h. Canonical link: https://commits.webkit.org/240343@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280758 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-07 18:50:12 +00:00
#include <wtf/LogChannels.h>
#include <wtf/text/WTFString.h>
Allow LOG macros to be used outside the namespace, and other logging cleanup https://bugs.webkit.org/show_bug.cgi?id=160216 Reviewed by Anders Carlsson. Source/WebCore: Fix some issues with the LOG macros. First, they were not usable outside the WebKit namespace in WebKit2 code. Fix by moving its log channels outside of the namespace (they are protected by a unique prefix anyway). Second, allow LOG_WITH_STREAM to be used in WebKit2 by moving that and a helper macro into LogMacros.h, which is exported from WebCore as a private header. Third, split the Logging.h header into two. Logging.h remains for framework-internal log channels and log macros. Add LogInitialization.h which is external, and used to initialize the channels. Finally unify "initializeLogChannels" and "initializeLoggingChannels" terminology everywhere. * WebCore.xcodeproj/project.pbxproj: * platform/LogInitialization.h: Added. * platform/LogMacros.h: Added. * platform/Logging.cpp: (WebCore::initializeLogChannelsIfNecessary): (WebCore::initializeLoggingChannelsIfNecessary): Deleted. * platform/Logging.h: * testing/js/WebCoreTestSupport.cpp: (WebCoreTestSupport::initializeLogChannelsIfNecessary): (WebCoreTestSupport::initializeLoggingChannelsIfNecessary): Deleted. * testing/js/WebCoreTestSupport.h: Source/WebKit: Fix some issues with the LOG macros. First, they were not usable outside the WebKit namespace in WebKit2 code. Fix by moving its log channels outside of the namespace (they are protected by a unique prefix anyway). Second, allow LOG_WITH_STREAM to be used in WebKit2 by moving that and a helper macro into LogMacros.h, which is exported from WebCore as a private header. Third, split the Logging.h header into two. Logging.h remains for framework-internal log channels and log macros. Add LogInitialization.h which is external, and used to initialize the channels. Finally unify "initializeLogChannels" and "initializeLoggingChannels" terminology everywhere. * WebCoreSupport/WebResourceLoadScheduler.cpp: Source/WebKit/mac: Fix some issues with the LOG macros. First, they were not usable outside the WebKit namespace in WebKit2 code. Fix by moving its log channels outside of the namespace (they are protected by a unique prefix anyway). Second, allow LOG_WITH_STREAM to be used in WebKit2 by moving that and a helper macro into LogMacros.h, which is exported from WebCore as a private header. Third, split the Logging.h header into two. Logging.h remains for framework-internal log channels and log macros. Add LogInitialization.h which is external, and used to initialize the channels. Finally unify "initializeLogChannels" and "initializeLoggingChannels" terminology everywhere. * Misc/WebKitLogging.h: * Misc/WebKitLogging.m: * WebView/WebView.mm: (-[WebView _commonInitializationWithFrameName:groupName:]): Source/WebKit/win: Fix some issues with the LOG macros. First, they were not usable outside the WebKit namespace in WebKit2 code. Fix by moving its log channels outside of the namespace (they are protected by a unique prefix anyway). Second, allow LOG_WITH_STREAM to be used in WebKit2 by moving that and a helper macro into LogMacros.h, which is exported from WebCore as a private header. Third, split the Logging.h header into two. Logging.h remains for framework-internal log channels and log macros. Add LogInitialization.h which is external, and used to initialize the channels. Finally unify "initializeLogChannels" and "initializeLoggingChannels" terminology everywhere. * WebKitLogging.cpp: * WebKitLogging.h: * WebView.cpp: (WebView::initWithFrame): Source/WebKit2: Fix some issues with the LOG macros. First, they were not usable outside the WebKit namespace in WebKit2 code. Fix by moving its log channels outside of the namespace (they are protected by a unique prefix anyway). Second, allow LOG_WITH_STREAM to be used in WebKit2 by moving that and a helper macro into LogMacros.h, which is exported from WebCore as a private header. Third, split the Logging.h header into two. Logging.h remains for framework-internal log channels and log macros. Add LogInitialization.h which is external, and used to initialize the channels. Finally unify "initializeLogChannels" and "initializeLoggingChannels" terminology everywhere. * NetworkProcess/NetworkProcess.cpp: * Platform/LogInitialization.h: Copied from Source/WebKit2/Platform/foundation/LoggingFoundation.mm. * Platform/Logging.cpp: (WebKit::initializeLogChannelsIfNecessary): * Platform/Logging.h: * Platform/foundation/LoggingFoundation.mm: * Shared/WebKit2Initialize.cpp: (WebKit::InitializeWebKit2): * UIProcess/API/Cocoa/WKWebView.mm: (-[WKWebView _updateContentRectsWithState:]): (-[WKWebView _navigationGestureDidBegin]): * UIProcess/WebProcessPool.cpp: (WebKit::m_hiddenPageThrottlingTimer): * WebKit2.xcodeproj/project.pbxproj: Tools: initializeLoggingChannelsIfNecessary -> initializeLogChannelsIfNecessary * DumpRenderTree/TestRunner.cpp: * DumpRenderTree/mac/DumpRenderTree.mm: (resetWebViewToConsistentStateBeforeTesting): Canonical link: https://commits.webkit.org/178378@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@203749 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-07-26 23:30:01 +00:00
namespace WebCore {
WebKit should set a subsystem for os_log so it's easier to filter for WebKit log messages https://bugs.webkit.org/show_bug.cgi?id=160969 <rdar://problem/26068734> Reviewed by Simon Fraser. Source/WebCore: - Specify a channel when using RELEASE_LOG macros - Add a new channel so that we have something to pass to the RELEASE_LOG macros (Layers). - Enable subsystem- and channel-related data and functions when using RELEASE_LOG macros. - Use the DECLARE_LOG_CHANNEL, DEFINE_LOG_CHANNEL, and LOG_CHANNEL_ADDRESS macros that are now defined in WTF. No new tests. There are no tests for logging. * loader/FrameLoader.cpp: * platform/LogInitialization.h: * platform/LogMacros.h: * platform/Logging.cpp: * platform/Logging.h: * platform/MemoryPressureHandler.cpp: (WebCore::MemoryPressureHandler::ReliefLogger::logMemoryUsageChange): * platform/graphics/cg/GraphicsContextCG.cpp: (WebCore::GraphicsContext::drawNativeImage): * platform/graphics/cocoa/IOSurface.mm: (WebCore::IOSurface::IOSurface): * platform/mac/LoggingMac.mm: * platform/unix/LoggingUnix.cpp: * platform/win/LoggingWin.cpp: * testing/js/WebCoreTestSupport.cpp: (WebCoreTestSupport::initializeLogChannelsIfNecessary): Source/WebKit/mac: Enable subsystem- and channel-related data and functions when using RELEASE_LOG macros. Use the DECLARE_LOG_CHANNEL, DEFINE_LOG_CHANNEL, and LOG_CHANNEL_ADDRESS macros that are now defined in WTF. * Misc/WebKitLogging.h: * Misc/WebKitLogging.m: * WebView/WebView.mm: (-[WebView _commonInitializationWithFrameName:groupName:]): Source/WebKit/win: Enable subsystem- and channel-related data and functions when using RELEASE_LOG macros. Use the DECLARE_LOG_CHANNEL, DEFINE_LOG_CHANNEL, and LOG_CHANNEL_ADDRESS macros that are now defined in WTF. * WebKitLogging.cpp: * WebKitLogging.h: * WebView.cpp: (WebView::initWithFrame): Source/WebKit2: - Specify a channel when using RELEASE_LOG macros. - Add some new channels so that we have something to pass to the RELEASE_LOG macros (ProcessSuspension, IPC, Layers). - Enable subsystem- and channel-related data and functions when using RELEASE_LOG macros. - Use the DECLARE_LOG_CHANNEL, DEFINE_LOG_CHANNEL, and LOG_CHANNEL_ADDRESS macros that are now defined in WTF. * NetworkProcess/Downloads/Download.cpp: * NetworkProcess/NetworkProcess.cpp: (WebKit::NetworkProcess::prepareToSuspend): (WebKit::NetworkProcess::cancelPrepareToSuspend): (WebKit::NetworkProcess::processDidResume): * NetworkProcess/NetworkResourceLoader.cpp: * Platform/IPC/Connection.cpp: (IPC::Connection::waitForSyncReply): * Platform/LogInitialization.h: * Platform/Logging.cpp: (WebKit::initializeLogChannelsIfNecessary): * Platform/Logging.h: * Platform/foundation/LoggingFoundation.mm: * Platform/unix/LoggingUnix.cpp: * Shared/ChildProcess.cpp: (WebKit::didCloseOnConnectionWorkQueue): * Shared/WebKit2Initialize.cpp: (WebKit::InitializeWebKit2): * UIProcess/Cocoa/NavigationState.mm: (WebKit::NavigationState::releaseNetworkActivityToken): (WebKit::NavigationState::didChangeIsLoading): * UIProcess/Network/NetworkProcessProxy.cpp: (WebKit::NetworkProcessProxy::fetchWebsiteData): (WebKit::NetworkProcessProxy::deleteWebsiteData): (WebKit::NetworkProcessProxy::deleteWebsiteDataForOrigins): (WebKit::NetworkProcessProxy::setIsHoldingLockedFiles): * UIProcess/ProcessThrottler.cpp: (WebKit::ProcessThrottler::updateAssertionNow): (WebKit::ProcessThrottler::updateAssertion): * UIProcess/WebPageProxy.cpp: * UIProcess/WebProcessPool.cpp: (WebKit::m_hiddenPageThrottlingTimer): * UIProcess/WebProcessProxy.cpp: (WebKit::WebProcessProxy::fetchWebsiteData): (WebKit::WebProcessProxy::deleteWebsiteData): (WebKit::WebProcessProxy::deleteWebsiteDataForOrigins): (WebKit::WebProcessProxy::didSetAssertionState): (WebKit::WebProcessProxy::setIsHoldingLockedFiles): * UIProcess/ios/ProcessAssertionIOS.mm: (-[WKProcessAssertionBackgroundTaskManager _updateBackgroundTask]): (WebKit::ProcessAssertion::ProcessAssertion): * WebProcess/Network/WebLoaderStrategy.cpp: * WebProcess/Network/WebResourceLoader.cpp: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::layerVolatilityTimerFired): * WebProcess/WebProcess.cpp: (WebKit::WebProcess::actualPrepareToSuspend): (WebKit::WebProcess::processWillSuspendImminently): (WebKit::WebProcess::prepareToSuspend): (WebKit::WebProcess::cancelPrepareToSuspend): (WebKit::WebProcess::markAllLayersVolatile): (WebKit::WebProcess::processDidResume): Source/WTF: Add support for attaching a subsystem and category when logging via the RELEASE_LOG macros. This support is provided by adding subsystem and category information to WTFLogChannel. An os_log_t object is then created to enacpsulate that information. When using RELEASE_LOG to log through that channel, the associated log object is used when calling os_log. To help support the inclusion of the subsystem and category information in WTFLogChannel, the DECLARE_LOG_CHANNEL, DEFINE_LOG_CHANNEL, and LOG_CHANNEL_ADDRESS macros that were defined in various modules are consolidated and moved to Assertions.h. DEFINE_LOG_CHANNEL is now defined to initialize the subsystem and category. * wtf/Assertions.cpp: * wtf/Assertions.h: * wtf/RefCountedLeakCounter.cpp: Canonical link: https://commits.webkit.org/179614@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@205275 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-01 01:33:40 +00:00
#if !LOG_DISABLED || !RELEASE_LOG_DISABLED
Allow LOG macros to be used outside the namespace, and other logging cleanup https://bugs.webkit.org/show_bug.cgi?id=160216 Reviewed by Anders Carlsson. Source/WebCore: Fix some issues with the LOG macros. First, they were not usable outside the WebKit namespace in WebKit2 code. Fix by moving its log channels outside of the namespace (they are protected by a unique prefix anyway). Second, allow LOG_WITH_STREAM to be used in WebKit2 by moving that and a helper macro into LogMacros.h, which is exported from WebCore as a private header. Third, split the Logging.h header into two. Logging.h remains for framework-internal log channels and log macros. Add LogInitialization.h which is external, and used to initialize the channels. Finally unify "initializeLogChannels" and "initializeLoggingChannels" terminology everywhere. * WebCore.xcodeproj/project.pbxproj: * platform/LogInitialization.h: Added. * platform/LogMacros.h: Added. * platform/Logging.cpp: (WebCore::initializeLogChannelsIfNecessary): (WebCore::initializeLoggingChannelsIfNecessary): Deleted. * platform/Logging.h: * testing/js/WebCoreTestSupport.cpp: (WebCoreTestSupport::initializeLogChannelsIfNecessary): (WebCoreTestSupport::initializeLoggingChannelsIfNecessary): Deleted. * testing/js/WebCoreTestSupport.h: Source/WebKit: Fix some issues with the LOG macros. First, they were not usable outside the WebKit namespace in WebKit2 code. Fix by moving its log channels outside of the namespace (they are protected by a unique prefix anyway). Second, allow LOG_WITH_STREAM to be used in WebKit2 by moving that and a helper macro into LogMacros.h, which is exported from WebCore as a private header. Third, split the Logging.h header into two. Logging.h remains for framework-internal log channels and log macros. Add LogInitialization.h which is external, and used to initialize the channels. Finally unify "initializeLogChannels" and "initializeLoggingChannels" terminology everywhere. * WebCoreSupport/WebResourceLoadScheduler.cpp: Source/WebKit/mac: Fix some issues with the LOG macros. First, they were not usable outside the WebKit namespace in WebKit2 code. Fix by moving its log channels outside of the namespace (they are protected by a unique prefix anyway). Second, allow LOG_WITH_STREAM to be used in WebKit2 by moving that and a helper macro into LogMacros.h, which is exported from WebCore as a private header. Third, split the Logging.h header into two. Logging.h remains for framework-internal log channels and log macros. Add LogInitialization.h which is external, and used to initialize the channels. Finally unify "initializeLogChannels" and "initializeLoggingChannels" terminology everywhere. * Misc/WebKitLogging.h: * Misc/WebKitLogging.m: * WebView/WebView.mm: (-[WebView _commonInitializationWithFrameName:groupName:]): Source/WebKit/win: Fix some issues with the LOG macros. First, they were not usable outside the WebKit namespace in WebKit2 code. Fix by moving its log channels outside of the namespace (they are protected by a unique prefix anyway). Second, allow LOG_WITH_STREAM to be used in WebKit2 by moving that and a helper macro into LogMacros.h, which is exported from WebCore as a private header. Third, split the Logging.h header into two. Logging.h remains for framework-internal log channels and log macros. Add LogInitialization.h which is external, and used to initialize the channels. Finally unify "initializeLogChannels" and "initializeLoggingChannels" terminology everywhere. * WebKitLogging.cpp: * WebKitLogging.h: * WebView.cpp: (WebView::initWithFrame): Source/WebKit2: Fix some issues with the LOG macros. First, they were not usable outside the WebKit namespace in WebKit2 code. Fix by moving its log channels outside of the namespace (they are protected by a unique prefix anyway). Second, allow LOG_WITH_STREAM to be used in WebKit2 by moving that and a helper macro into LogMacros.h, which is exported from WebCore as a private header. Third, split the Logging.h header into two. Logging.h remains for framework-internal log channels and log macros. Add LogInitialization.h which is external, and used to initialize the channels. Finally unify "initializeLogChannels" and "initializeLoggingChannels" terminology everywhere. * NetworkProcess/NetworkProcess.cpp: * Platform/LogInitialization.h: Copied from Source/WebKit2/Platform/foundation/LoggingFoundation.mm. * Platform/Logging.cpp: (WebKit::initializeLogChannelsIfNecessary): * Platform/Logging.h: * Platform/foundation/LoggingFoundation.mm: * Shared/WebKit2Initialize.cpp: (WebKit::InitializeWebKit2): * UIProcess/API/Cocoa/WKWebView.mm: (-[WKWebView _updateContentRectsWithState:]): (-[WKWebView _navigationGestureDidBegin]): * UIProcess/WebProcessPool.cpp: (WebKit::m_hiddenPageThrottlingTimer): * WebKit2.xcodeproj/project.pbxproj: Tools: initializeLoggingChannelsIfNecessary -> initializeLogChannelsIfNecessary * DumpRenderTree/TestRunner.cpp: * DumpRenderTree/mac/DumpRenderTree.mm: (resetWebViewToConsistentStateBeforeTesting): Canonical link: https://commits.webkit.org/178378@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@203749 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-07-26 23:30:01 +00:00
Deduplicate logging channel algorithms https://bugs.webkit.org/show_bug.cgi?id=228809 Reviewed by Fujii Hironori. Source/WebCore: No new tests because there is no behavior change. * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * accessibility/AXLogger.cpp: * inspector/agents/page/PageConsoleAgent.cpp: * page/Page.cpp: * platform/LogInitialization.cpp: Copied from Source/WebCore/platform/LogInitialization.h. (WebCore::logChannels): (WebCore::getLogChannel): * platform/LogInitialization.h: * platform/Logging.cpp: (WebCore::isLogChannelEnabled): Deleted. (WebCore::setLogChannelToAccumulate): Deleted. (WebCore::clearAllLogChannelsToAccumulate): Deleted. (WebCore::initializeLogChannelsIfNecessary): Deleted. (WebCore::getLogChannel): Deleted. * platform/Logging.h: * testing/js/WebCoreTestSupport.cpp: (WebCoreTestSupport::setLogChannelToAccumulate): (WebCoreTestSupport::clearAllLogChannelsToAccumulate): (WebCoreTestSupport::initializeLogChannelsIfNecessary): Source/WebKit: * GPUProcess/GPUConnectionToWebProcess.cpp: * GPUProcess/GPUProcess.cpp: (WebKit::GPUProcess::initializeGPUProcess): * Platform/LogInitialization.cpp: Copied from Source/WebKit/Shared/WebKit2Initialize.cpp. (WebKit::logChannels): (WebKit::getLogChannel): * Platform/LogInitialization.h: * Platform/Logging.cpp: (WebKit::initializeLogChannelsIfNecessary): Deleted. (WebKit::getLogChannel): Deleted. * Platform/Logging.h: * Shared/AuxiliaryProcess.cpp: (WebKit::AuxiliaryProcess::initialize): * Shared/WebKit2Initialize.cpp: (WebKit::InitializeWebKit2): * Sources.txt: * UIProcess/WebPageProxy.cpp: * UIProcess/WebProcessPool.cpp: * WebKit.xcodeproj/project.pbxproj: * WebProcess/cocoa/WebProcessCocoa.mm: (WebKit::WebProcess::platformInitializeWebProcess): Source/WebKitLegacy: * WebKitLegacy.xcodeproj/project.pbxproj: Source/WebKitLegacy/mac: * Misc/WebKitLogInitialization.h: Copied from Source/WebKit/Platform/LogInitialization.h. * Misc/WebKitLogInitialization.mm: Copied from Source/WebKitLegacy/mac/Misc/WebKitLogging.m. (WebKit::logChannels): (ReportDiscardedDelegateException): * Misc/WebKitLogging.h: * Misc/WebKitLogging.m: (ReportDiscardedDelegateException): Deleted. * WebCoreSupport/WebDragClient.mm: * WebView/WebDelegateImplementationCaching.mm: * WebView/WebView.mm: (-[WebView _commonInitializationWithFrameName:groupName:]): Source/WTF: The current infrastructure (before this patch) had the following duplicated for each framework: - A .cpp file declared the list of logging channels for that framework - The .cpp file also had algorithms to search, modify, and initialize these logging channels Each framework's .cpp file had duplicate algorithms. (The initialization algorithm was even duplicated 3 times!) Because the algorithms directly name their specific list of logging channels, a naive deduplication would have had to add new parameters to these algorithms to pass in the appropriate framework's list. That's fine, but this is exactly the sort of thing classes were designed for - classes are an association of algorithms and data. The algorithms are shared but the data isn't, which really just means we should have 3 instances of a shared class - one for the 3 sets of data. So, this patch creates the LogChannels class which contains the deduplicated algorithms, and each framework has a NeverDestroyed singleton instance of that class. There is a single virtual method in the class, so the appropriate "default write" variable can be queried for each framework. The instances cannot be declared in the Logging.h files in the frameworks, because certain WebKit2 files want to initialize all 3 instances of LogChannels, but you can't #include multiple Logging.h files at the same time because their LOG_CHANNEL_PREFIX #defines will collide with each other. Luckily, LogInitialization.h files exist exactly to solve this purpose, so that's where the LogChannels instances are declared in. After this change, the Logging.h files are just for the declarations of the logging channels themselves, and the LogInitialization.h files are for the LogChannels instances which contain the searching/modifying/initializing algorithms on the list of logging channels. If you just want to LOG(...) something, #include the relevant Logging.h file, and if you want to search/modify/initialize across the entire list of channels, then #include the relevant LogInitialization.h file. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/LogChannels.cpp: Copied from Source/WebCore/platform/Logging.cpp. (WTF::LogChannels::isLogChannelEnabled): (WTF::LogChannels::setLogChannelToAccumulate): (WTF::LogChannels::clearAllLogChannelsToAccumulate): (WTF::LogChannels::initializeLogChannelsIfNecessary): (WTF::LogChannels::getLogChannel): * wtf/LogChannels.h: Copied from Source/WebCore/platform/LogInitialization.h. Canonical link: https://commits.webkit.org/240343@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280758 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-07 18:50:12 +00:00
WEBCORE_EXPORT WTF::LogChannels& logChannels();
String logLevelString();
Allow LOG macros to be used outside the namespace, and other logging cleanup https://bugs.webkit.org/show_bug.cgi?id=160216 Reviewed by Anders Carlsson. Source/WebCore: Fix some issues with the LOG macros. First, they were not usable outside the WebKit namespace in WebKit2 code. Fix by moving its log channels outside of the namespace (they are protected by a unique prefix anyway). Second, allow LOG_WITH_STREAM to be used in WebKit2 by moving that and a helper macro into LogMacros.h, which is exported from WebCore as a private header. Third, split the Logging.h header into two. Logging.h remains for framework-internal log channels and log macros. Add LogInitialization.h which is external, and used to initialize the channels. Finally unify "initializeLogChannels" and "initializeLoggingChannels" terminology everywhere. * WebCore.xcodeproj/project.pbxproj: * platform/LogInitialization.h: Added. * platform/LogMacros.h: Added. * platform/Logging.cpp: (WebCore::initializeLogChannelsIfNecessary): (WebCore::initializeLoggingChannelsIfNecessary): Deleted. * platform/Logging.h: * testing/js/WebCoreTestSupport.cpp: (WebCoreTestSupport::initializeLogChannelsIfNecessary): (WebCoreTestSupport::initializeLoggingChannelsIfNecessary): Deleted. * testing/js/WebCoreTestSupport.h: Source/WebKit: Fix some issues with the LOG macros. First, they were not usable outside the WebKit namespace in WebKit2 code. Fix by moving its log channels outside of the namespace (they are protected by a unique prefix anyway). Second, allow LOG_WITH_STREAM to be used in WebKit2 by moving that and a helper macro into LogMacros.h, which is exported from WebCore as a private header. Third, split the Logging.h header into two. Logging.h remains for framework-internal log channels and log macros. Add LogInitialization.h which is external, and used to initialize the channels. Finally unify "initializeLogChannels" and "initializeLoggingChannels" terminology everywhere. * WebCoreSupport/WebResourceLoadScheduler.cpp: Source/WebKit/mac: Fix some issues with the LOG macros. First, they were not usable outside the WebKit namespace in WebKit2 code. Fix by moving its log channels outside of the namespace (they are protected by a unique prefix anyway). Second, allow LOG_WITH_STREAM to be used in WebKit2 by moving that and a helper macro into LogMacros.h, which is exported from WebCore as a private header. Third, split the Logging.h header into two. Logging.h remains for framework-internal log channels and log macros. Add LogInitialization.h which is external, and used to initialize the channels. Finally unify "initializeLogChannels" and "initializeLoggingChannels" terminology everywhere. * Misc/WebKitLogging.h: * Misc/WebKitLogging.m: * WebView/WebView.mm: (-[WebView _commonInitializationWithFrameName:groupName:]): Source/WebKit/win: Fix some issues with the LOG macros. First, they were not usable outside the WebKit namespace in WebKit2 code. Fix by moving its log channels outside of the namespace (they are protected by a unique prefix anyway). Second, allow LOG_WITH_STREAM to be used in WebKit2 by moving that and a helper macro into LogMacros.h, which is exported from WebCore as a private header. Third, split the Logging.h header into two. Logging.h remains for framework-internal log channels and log macros. Add LogInitialization.h which is external, and used to initialize the channels. Finally unify "initializeLogChannels" and "initializeLoggingChannels" terminology everywhere. * WebKitLogging.cpp: * WebKitLogging.h: * WebView.cpp: (WebView::initWithFrame): Source/WebKit2: Fix some issues with the LOG macros. First, they were not usable outside the WebKit namespace in WebKit2 code. Fix by moving its log channels outside of the namespace (they are protected by a unique prefix anyway). Second, allow LOG_WITH_STREAM to be used in WebKit2 by moving that and a helper macro into LogMacros.h, which is exported from WebCore as a private header. Third, split the Logging.h header into two. Logging.h remains for framework-internal log channels and log macros. Add LogInitialization.h which is external, and used to initialize the channels. Finally unify "initializeLogChannels" and "initializeLoggingChannels" terminology everywhere. * NetworkProcess/NetworkProcess.cpp: * Platform/LogInitialization.h: Copied from Source/WebKit2/Platform/foundation/LoggingFoundation.mm. * Platform/Logging.cpp: (WebKit::initializeLogChannelsIfNecessary): * Platform/Logging.h: * Platform/foundation/LoggingFoundation.mm: * Shared/WebKit2Initialize.cpp: (WebKit::InitializeWebKit2): * UIProcess/API/Cocoa/WKWebView.mm: (-[WKWebView _updateContentRectsWithState:]): (-[WKWebView _navigationGestureDidBegin]): * UIProcess/WebProcessPool.cpp: (WebKit::m_hiddenPageThrottlingTimer): * WebKit2.xcodeproj/project.pbxproj: Tools: initializeLoggingChannelsIfNecessary -> initializeLogChannelsIfNecessary * DumpRenderTree/TestRunner.cpp: * DumpRenderTree/mac/DumpRenderTree.mm: (resetWebViewToConsistentStateBeforeTesting): Canonical link: https://commits.webkit.org/178378@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@203749 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-07-26 23:30:01 +00:00
WebKit should set a subsystem for os_log so it's easier to filter for WebKit log messages https://bugs.webkit.org/show_bug.cgi?id=160969 <rdar://problem/26068734> Reviewed by Simon Fraser. Source/WebCore: - Specify a channel when using RELEASE_LOG macros - Add a new channel so that we have something to pass to the RELEASE_LOG macros (Layers). - Enable subsystem- and channel-related data and functions when using RELEASE_LOG macros. - Use the DECLARE_LOG_CHANNEL, DEFINE_LOG_CHANNEL, and LOG_CHANNEL_ADDRESS macros that are now defined in WTF. No new tests. There are no tests for logging. * loader/FrameLoader.cpp: * platform/LogInitialization.h: * platform/LogMacros.h: * platform/Logging.cpp: * platform/Logging.h: * platform/MemoryPressureHandler.cpp: (WebCore::MemoryPressureHandler::ReliefLogger::logMemoryUsageChange): * platform/graphics/cg/GraphicsContextCG.cpp: (WebCore::GraphicsContext::drawNativeImage): * platform/graphics/cocoa/IOSurface.mm: (WebCore::IOSurface::IOSurface): * platform/mac/LoggingMac.mm: * platform/unix/LoggingUnix.cpp: * platform/win/LoggingWin.cpp: * testing/js/WebCoreTestSupport.cpp: (WebCoreTestSupport::initializeLogChannelsIfNecessary): Source/WebKit/mac: Enable subsystem- and channel-related data and functions when using RELEASE_LOG macros. Use the DECLARE_LOG_CHANNEL, DEFINE_LOG_CHANNEL, and LOG_CHANNEL_ADDRESS macros that are now defined in WTF. * Misc/WebKitLogging.h: * Misc/WebKitLogging.m: * WebView/WebView.mm: (-[WebView _commonInitializationWithFrameName:groupName:]): Source/WebKit/win: Enable subsystem- and channel-related data and functions when using RELEASE_LOG macros. Use the DECLARE_LOG_CHANNEL, DEFINE_LOG_CHANNEL, and LOG_CHANNEL_ADDRESS macros that are now defined in WTF. * WebKitLogging.cpp: * WebKitLogging.h: * WebView.cpp: (WebView::initWithFrame): Source/WebKit2: - Specify a channel when using RELEASE_LOG macros. - Add some new channels so that we have something to pass to the RELEASE_LOG macros (ProcessSuspension, IPC, Layers). - Enable subsystem- and channel-related data and functions when using RELEASE_LOG macros. - Use the DECLARE_LOG_CHANNEL, DEFINE_LOG_CHANNEL, and LOG_CHANNEL_ADDRESS macros that are now defined in WTF. * NetworkProcess/Downloads/Download.cpp: * NetworkProcess/NetworkProcess.cpp: (WebKit::NetworkProcess::prepareToSuspend): (WebKit::NetworkProcess::cancelPrepareToSuspend): (WebKit::NetworkProcess::processDidResume): * NetworkProcess/NetworkResourceLoader.cpp: * Platform/IPC/Connection.cpp: (IPC::Connection::waitForSyncReply): * Platform/LogInitialization.h: * Platform/Logging.cpp: (WebKit::initializeLogChannelsIfNecessary): * Platform/Logging.h: * Platform/foundation/LoggingFoundation.mm: * Platform/unix/LoggingUnix.cpp: * Shared/ChildProcess.cpp: (WebKit::didCloseOnConnectionWorkQueue): * Shared/WebKit2Initialize.cpp: (WebKit::InitializeWebKit2): * UIProcess/Cocoa/NavigationState.mm: (WebKit::NavigationState::releaseNetworkActivityToken): (WebKit::NavigationState::didChangeIsLoading): * UIProcess/Network/NetworkProcessProxy.cpp: (WebKit::NetworkProcessProxy::fetchWebsiteData): (WebKit::NetworkProcessProxy::deleteWebsiteData): (WebKit::NetworkProcessProxy::deleteWebsiteDataForOrigins): (WebKit::NetworkProcessProxy::setIsHoldingLockedFiles): * UIProcess/ProcessThrottler.cpp: (WebKit::ProcessThrottler::updateAssertionNow): (WebKit::ProcessThrottler::updateAssertion): * UIProcess/WebPageProxy.cpp: * UIProcess/WebProcessPool.cpp: (WebKit::m_hiddenPageThrottlingTimer): * UIProcess/WebProcessProxy.cpp: (WebKit::WebProcessProxy::fetchWebsiteData): (WebKit::WebProcessProxy::deleteWebsiteData): (WebKit::WebProcessProxy::deleteWebsiteDataForOrigins): (WebKit::WebProcessProxy::didSetAssertionState): (WebKit::WebProcessProxy::setIsHoldingLockedFiles): * UIProcess/ios/ProcessAssertionIOS.mm: (-[WKProcessAssertionBackgroundTaskManager _updateBackgroundTask]): (WebKit::ProcessAssertion::ProcessAssertion): * WebProcess/Network/WebLoaderStrategy.cpp: * WebProcess/Network/WebResourceLoader.cpp: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::layerVolatilityTimerFired): * WebProcess/WebProcess.cpp: (WebKit::WebProcess::actualPrepareToSuspend): (WebKit::WebProcess::processWillSuspendImminently): (WebKit::WebProcess::prepareToSuspend): (WebKit::WebProcess::cancelPrepareToSuspend): (WebKit::WebProcess::markAllLayersVolatile): (WebKit::WebProcess::processDidResume): Source/WTF: Add support for attaching a subsystem and category when logging via the RELEASE_LOG macros. This support is provided by adding subsystem and category information to WTFLogChannel. An os_log_t object is then created to enacpsulate that information. When using RELEASE_LOG to log through that channel, the associated log object is used when calling os_log. To help support the inclusion of the subsystem and category information in WTFLogChannel, the DECLARE_LOG_CHANNEL, DEFINE_LOG_CHANNEL, and LOG_CHANNEL_ADDRESS macros that were defined in various modules are consolidated and moved to Assertions.h. DEFINE_LOG_CHANNEL is now defined to initialize the subsystem and category. * wtf/Assertions.cpp: * wtf/Assertions.h: * wtf/RefCountedLeakCounter.cpp: Canonical link: https://commits.webkit.org/179614@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@205275 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-01 01:33:40 +00:00
#endif // !LOG_DISABLED || !RELEASE_LOG_DISABLED
Allow LOG macros to be used outside the namespace, and other logging cleanup https://bugs.webkit.org/show_bug.cgi?id=160216 Reviewed by Anders Carlsson. Source/WebCore: Fix some issues with the LOG macros. First, they were not usable outside the WebKit namespace in WebKit2 code. Fix by moving its log channels outside of the namespace (they are protected by a unique prefix anyway). Second, allow LOG_WITH_STREAM to be used in WebKit2 by moving that and a helper macro into LogMacros.h, which is exported from WebCore as a private header. Third, split the Logging.h header into two. Logging.h remains for framework-internal log channels and log macros. Add LogInitialization.h which is external, and used to initialize the channels. Finally unify "initializeLogChannels" and "initializeLoggingChannels" terminology everywhere. * WebCore.xcodeproj/project.pbxproj: * platform/LogInitialization.h: Added. * platform/LogMacros.h: Added. * platform/Logging.cpp: (WebCore::initializeLogChannelsIfNecessary): (WebCore::initializeLoggingChannelsIfNecessary): Deleted. * platform/Logging.h: * testing/js/WebCoreTestSupport.cpp: (WebCoreTestSupport::initializeLogChannelsIfNecessary): (WebCoreTestSupport::initializeLoggingChannelsIfNecessary): Deleted. * testing/js/WebCoreTestSupport.h: Source/WebKit: Fix some issues with the LOG macros. First, they were not usable outside the WebKit namespace in WebKit2 code. Fix by moving its log channels outside of the namespace (they are protected by a unique prefix anyway). Second, allow LOG_WITH_STREAM to be used in WebKit2 by moving that and a helper macro into LogMacros.h, which is exported from WebCore as a private header. Third, split the Logging.h header into two. Logging.h remains for framework-internal log channels and log macros. Add LogInitialization.h which is external, and used to initialize the channels. Finally unify "initializeLogChannels" and "initializeLoggingChannels" terminology everywhere. * WebCoreSupport/WebResourceLoadScheduler.cpp: Source/WebKit/mac: Fix some issues with the LOG macros. First, they were not usable outside the WebKit namespace in WebKit2 code. Fix by moving its log channels outside of the namespace (they are protected by a unique prefix anyway). Second, allow LOG_WITH_STREAM to be used in WebKit2 by moving that and a helper macro into LogMacros.h, which is exported from WebCore as a private header. Third, split the Logging.h header into two. Logging.h remains for framework-internal log channels and log macros. Add LogInitialization.h which is external, and used to initialize the channels. Finally unify "initializeLogChannels" and "initializeLoggingChannels" terminology everywhere. * Misc/WebKitLogging.h: * Misc/WebKitLogging.m: * WebView/WebView.mm: (-[WebView _commonInitializationWithFrameName:groupName:]): Source/WebKit/win: Fix some issues with the LOG macros. First, they were not usable outside the WebKit namespace in WebKit2 code. Fix by moving its log channels outside of the namespace (they are protected by a unique prefix anyway). Second, allow LOG_WITH_STREAM to be used in WebKit2 by moving that and a helper macro into LogMacros.h, which is exported from WebCore as a private header. Third, split the Logging.h header into two. Logging.h remains for framework-internal log channels and log macros. Add LogInitialization.h which is external, and used to initialize the channels. Finally unify "initializeLogChannels" and "initializeLoggingChannels" terminology everywhere. * WebKitLogging.cpp: * WebKitLogging.h: * WebView.cpp: (WebView::initWithFrame): Source/WebKit2: Fix some issues with the LOG macros. First, they were not usable outside the WebKit namespace in WebKit2 code. Fix by moving its log channels outside of the namespace (they are protected by a unique prefix anyway). Second, allow LOG_WITH_STREAM to be used in WebKit2 by moving that and a helper macro into LogMacros.h, which is exported from WebCore as a private header. Third, split the Logging.h header into two. Logging.h remains for framework-internal log channels and log macros. Add LogInitialization.h which is external, and used to initialize the channels. Finally unify "initializeLogChannels" and "initializeLoggingChannels" terminology everywhere. * NetworkProcess/NetworkProcess.cpp: * Platform/LogInitialization.h: Copied from Source/WebKit2/Platform/foundation/LoggingFoundation.mm. * Platform/Logging.cpp: (WebKit::initializeLogChannelsIfNecessary): * Platform/Logging.h: * Platform/foundation/LoggingFoundation.mm: * Shared/WebKit2Initialize.cpp: (WebKit::InitializeWebKit2): * UIProcess/API/Cocoa/WKWebView.mm: (-[WKWebView _updateContentRectsWithState:]): (-[WKWebView _navigationGestureDidBegin]): * UIProcess/WebProcessPool.cpp: (WebKit::m_hiddenPageThrottlingTimer): * WebKit2.xcodeproj/project.pbxproj: Tools: initializeLoggingChannelsIfNecessary -> initializeLogChannelsIfNecessary * DumpRenderTree/TestRunner.cpp: * DumpRenderTree/mac/DumpRenderTree.mm: (resetWebViewToConsistentStateBeforeTesting): Canonical link: https://commits.webkit.org/178378@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@203749 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-07-26 23:30:01 +00:00
Deduplicate logging channel algorithms https://bugs.webkit.org/show_bug.cgi?id=228809 Reviewed by Fujii Hironori. Source/WebCore: No new tests because there is no behavior change. * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * accessibility/AXLogger.cpp: * inspector/agents/page/PageConsoleAgent.cpp: * page/Page.cpp: * platform/LogInitialization.cpp: Copied from Source/WebCore/platform/LogInitialization.h. (WebCore::logChannels): (WebCore::getLogChannel): * platform/LogInitialization.h: * platform/Logging.cpp: (WebCore::isLogChannelEnabled): Deleted. (WebCore::setLogChannelToAccumulate): Deleted. (WebCore::clearAllLogChannelsToAccumulate): Deleted. (WebCore::initializeLogChannelsIfNecessary): Deleted. (WebCore::getLogChannel): Deleted. * platform/Logging.h: * testing/js/WebCoreTestSupport.cpp: (WebCoreTestSupport::setLogChannelToAccumulate): (WebCoreTestSupport::clearAllLogChannelsToAccumulate): (WebCoreTestSupport::initializeLogChannelsIfNecessary): Source/WebKit: * GPUProcess/GPUConnectionToWebProcess.cpp: * GPUProcess/GPUProcess.cpp: (WebKit::GPUProcess::initializeGPUProcess): * Platform/LogInitialization.cpp: Copied from Source/WebKit/Shared/WebKit2Initialize.cpp. (WebKit::logChannels): (WebKit::getLogChannel): * Platform/LogInitialization.h: * Platform/Logging.cpp: (WebKit::initializeLogChannelsIfNecessary): Deleted. (WebKit::getLogChannel): Deleted. * Platform/Logging.h: * Shared/AuxiliaryProcess.cpp: (WebKit::AuxiliaryProcess::initialize): * Shared/WebKit2Initialize.cpp: (WebKit::InitializeWebKit2): * Sources.txt: * UIProcess/WebPageProxy.cpp: * UIProcess/WebProcessPool.cpp: * WebKit.xcodeproj/project.pbxproj: * WebProcess/cocoa/WebProcessCocoa.mm: (WebKit::WebProcess::platformInitializeWebProcess): Source/WebKitLegacy: * WebKitLegacy.xcodeproj/project.pbxproj: Source/WebKitLegacy/mac: * Misc/WebKitLogInitialization.h: Copied from Source/WebKit/Platform/LogInitialization.h. * Misc/WebKitLogInitialization.mm: Copied from Source/WebKitLegacy/mac/Misc/WebKitLogging.m. (WebKit::logChannels): (ReportDiscardedDelegateException): * Misc/WebKitLogging.h: * Misc/WebKitLogging.m: (ReportDiscardedDelegateException): Deleted. * WebCoreSupport/WebDragClient.mm: * WebView/WebDelegateImplementationCaching.mm: * WebView/WebView.mm: (-[WebView _commonInitializationWithFrameName:groupName:]): Source/WTF: The current infrastructure (before this patch) had the following duplicated for each framework: - A .cpp file declared the list of logging channels for that framework - The .cpp file also had algorithms to search, modify, and initialize these logging channels Each framework's .cpp file had duplicate algorithms. (The initialization algorithm was even duplicated 3 times!) Because the algorithms directly name their specific list of logging channels, a naive deduplication would have had to add new parameters to these algorithms to pass in the appropriate framework's list. That's fine, but this is exactly the sort of thing classes were designed for - classes are an association of algorithms and data. The algorithms are shared but the data isn't, which really just means we should have 3 instances of a shared class - one for the 3 sets of data. So, this patch creates the LogChannels class which contains the deduplicated algorithms, and each framework has a NeverDestroyed singleton instance of that class. There is a single virtual method in the class, so the appropriate "default write" variable can be queried for each framework. The instances cannot be declared in the Logging.h files in the frameworks, because certain WebKit2 files want to initialize all 3 instances of LogChannels, but you can't #include multiple Logging.h files at the same time because their LOG_CHANNEL_PREFIX #defines will collide with each other. Luckily, LogInitialization.h files exist exactly to solve this purpose, so that's where the LogChannels instances are declared in. After this change, the Logging.h files are just for the declarations of the logging channels themselves, and the LogInitialization.h files are for the LogChannels instances which contain the searching/modifying/initializing algorithms on the list of logging channels. If you just want to LOG(...) something, #include the relevant Logging.h file, and if you want to search/modify/initialize across the entire list of channels, then #include the relevant LogInitialization.h file. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/LogChannels.cpp: Copied from Source/WebCore/platform/Logging.cpp. (WTF::LogChannels::isLogChannelEnabled): (WTF::LogChannels::setLogChannelToAccumulate): (WTF::LogChannels::clearAllLogChannelsToAccumulate): (WTF::LogChannels::initializeLogChannelsIfNecessary): (WTF::LogChannels::getLogChannel): * wtf/LogChannels.h: Copied from Source/WebCore/platform/LogInitialization.h. Canonical link: https://commits.webkit.org/240343@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280758 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-07 18:50:12 +00:00
WEBCORE_EXPORT WTFLogChannel* getLogChannel(const String& name);
Allow LOG macros to be used outside the namespace, and other logging cleanup https://bugs.webkit.org/show_bug.cgi?id=160216 Reviewed by Anders Carlsson. Source/WebCore: Fix some issues with the LOG macros. First, they were not usable outside the WebKit namespace in WebKit2 code. Fix by moving its log channels outside of the namespace (they are protected by a unique prefix anyway). Second, allow LOG_WITH_STREAM to be used in WebKit2 by moving that and a helper macro into LogMacros.h, which is exported from WebCore as a private header. Third, split the Logging.h header into two. Logging.h remains for framework-internal log channels and log macros. Add LogInitialization.h which is external, and used to initialize the channels. Finally unify "initializeLogChannels" and "initializeLoggingChannels" terminology everywhere. * WebCore.xcodeproj/project.pbxproj: * platform/LogInitialization.h: Added. * platform/LogMacros.h: Added. * platform/Logging.cpp: (WebCore::initializeLogChannelsIfNecessary): (WebCore::initializeLoggingChannelsIfNecessary): Deleted. * platform/Logging.h: * testing/js/WebCoreTestSupport.cpp: (WebCoreTestSupport::initializeLogChannelsIfNecessary): (WebCoreTestSupport::initializeLoggingChannelsIfNecessary): Deleted. * testing/js/WebCoreTestSupport.h: Source/WebKit: Fix some issues with the LOG macros. First, they were not usable outside the WebKit namespace in WebKit2 code. Fix by moving its log channels outside of the namespace (they are protected by a unique prefix anyway). Second, allow LOG_WITH_STREAM to be used in WebKit2 by moving that and a helper macro into LogMacros.h, which is exported from WebCore as a private header. Third, split the Logging.h header into two. Logging.h remains for framework-internal log channels and log macros. Add LogInitialization.h which is external, and used to initialize the channels. Finally unify "initializeLogChannels" and "initializeLoggingChannels" terminology everywhere. * WebCoreSupport/WebResourceLoadScheduler.cpp: Source/WebKit/mac: Fix some issues with the LOG macros. First, they were not usable outside the WebKit namespace in WebKit2 code. Fix by moving its log channels outside of the namespace (they are protected by a unique prefix anyway). Second, allow LOG_WITH_STREAM to be used in WebKit2 by moving that and a helper macro into LogMacros.h, which is exported from WebCore as a private header. Third, split the Logging.h header into two. Logging.h remains for framework-internal log channels and log macros. Add LogInitialization.h which is external, and used to initialize the channels. Finally unify "initializeLogChannels" and "initializeLoggingChannels" terminology everywhere. * Misc/WebKitLogging.h: * Misc/WebKitLogging.m: * WebView/WebView.mm: (-[WebView _commonInitializationWithFrameName:groupName:]): Source/WebKit/win: Fix some issues with the LOG macros. First, they were not usable outside the WebKit namespace in WebKit2 code. Fix by moving its log channels outside of the namespace (they are protected by a unique prefix anyway). Second, allow LOG_WITH_STREAM to be used in WebKit2 by moving that and a helper macro into LogMacros.h, which is exported from WebCore as a private header. Third, split the Logging.h header into two. Logging.h remains for framework-internal log channels and log macros. Add LogInitialization.h which is external, and used to initialize the channels. Finally unify "initializeLogChannels" and "initializeLoggingChannels" terminology everywhere. * WebKitLogging.cpp: * WebKitLogging.h: * WebView.cpp: (WebView::initWithFrame): Source/WebKit2: Fix some issues with the LOG macros. First, they were not usable outside the WebKit namespace in WebKit2 code. Fix by moving its log channels outside of the namespace (they are protected by a unique prefix anyway). Second, allow LOG_WITH_STREAM to be used in WebKit2 by moving that and a helper macro into LogMacros.h, which is exported from WebCore as a private header. Third, split the Logging.h header into two. Logging.h remains for framework-internal log channels and log macros. Add LogInitialization.h which is external, and used to initialize the channels. Finally unify "initializeLogChannels" and "initializeLoggingChannels" terminology everywhere. * NetworkProcess/NetworkProcess.cpp: * Platform/LogInitialization.h: Copied from Source/WebKit2/Platform/foundation/LoggingFoundation.mm. * Platform/Logging.cpp: (WebKit::initializeLogChannelsIfNecessary): * Platform/Logging.h: * Platform/foundation/LoggingFoundation.mm: * Shared/WebKit2Initialize.cpp: (WebKit::InitializeWebKit2): * UIProcess/API/Cocoa/WKWebView.mm: (-[WKWebView _updateContentRectsWithState:]): (-[WKWebView _navigationGestureDidBegin]): * UIProcess/WebProcessPool.cpp: (WebKit::m_hiddenPageThrottlingTimer): * WebKit2.xcodeproj/project.pbxproj: Tools: initializeLoggingChannelsIfNecessary -> initializeLogChannelsIfNecessary * DumpRenderTree/TestRunner.cpp: * DumpRenderTree/mac/DumpRenderTree.mm: (resetWebViewToConsistentStateBeforeTesting): Canonical link: https://commits.webkit.org/178378@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@203749 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-07-26 23:30:01 +00:00
} // namespace WebCore