Logging should be configurable using human-readable channel names rather than crazy...
authormrowe@apple.com <mrowe@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 Aug 2013 02:53:49 +0000 (02:53 +0000)
committermrowe@apple.com <mrowe@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 Aug 2013 02:53:49 +0000 (02:53 +0000)
commita8e34f06a654e167ee8f758a043b3c6fc1c60f70
tree9df87ca88029dd53fabe73b7571e5cd89cc3ed95
parent0ed9e0893394203e38489b61dd88c84a3c27358b
Logging should be configurable using human-readable channel names rather than crazy bitmasks
<http://webkit.org/b/119031>

Implement shared logic for initializing logging channels based on human-readable channel names in WTF,
and rework the WebCore, WebKit and WebKit2 logging initialization on top of it.

Logging channels may now be enabled by providing a comma-separated list of channel names, with the special
"all" name enabling all channels. Channel names prefixed with a leading "-" will result in the named channel
being disabled. For instance, specifying "all,-history,-loading" will result in all logging channels except
for history and loading being enabled.

For OS X developers, this also changes the name of the user defaults used to enable logging. This is done to allow
the old user defaults to remain set for those people that need to switch between version of WebKit before and
after this change. Where the old user default keys were WebCoreLogLevel, WebKitLogLevel and WebKit2LogLevel,
the new user default keys are WebCoreLogging, WebKitLogging and WebKit2Logging.

For GTK developers, this changes the separator used in the WEBKIT_DEBUG environment variable to a comma for
consistency with the other platforms and to enable more code sharing.

While doing this work I've also taken the opportunity to eliminate the need to touch multiple files when
adding a new logging channel. Now only the header in the relevant project needs to be updated.

Reviewed by Sam Weinig.

Source/WebCore:

* GNUmakefile.list.am: Remove the now-unused InitializeLogging.h
* Target.pri: Ditto.
* WebCore.xcodeproj/project.pbxproj: Ditto.
* platform/InitializeLogging.h: Removed. Ditto.
* platform/Logging.cpp: Use WEBCORE_LOG_CHANNELS to define all of the channels.
(WebCore::logChannelByName): Renamed to match our naming conventions. Calls through to the new WTF function
to find a log channel rather than repeating the names of the log channels a further two times each.
(WebCore::initializeLoggingChannelsIfNecessary): Pass the channels and the log level string to the new
WTF function that handles the initialization.
* platform/Logging.h: Declare a WEBCORE_LOG_CHANNELS macro that can be used to apply a preprocessor macro
across the set of all logging channels. Use this macro to declare the logging channels.
* platform/blackberry/LoggingBlackBerry.cpp:
(WebCore::logLevelString): Pull the value out of the WEBKIT_DEBUG environment variable.
* platform/efl/LoggingEfl.cpp:
(WebCore::logLevelString): Pull the value out of the WEBKIT_DEBUG environment variable, and then prepend
NotYetImplemented to it so that that channel will be enabled by default.
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
(WebCore::MediaPlayerPrivateGStreamerBase::createVideoSink): Accommodate the rename to logChannelByName.
* platform/gtk/LoggingGtk.cpp:
(WebCore::logLevelString): Pull the value out of the WEBKIT_DEBUG environment variable, and then prepend
NotYetImplemented to it so that that channel will be enabled by default.
* platform/mac/LoggingMac.mm:
(WebCore::logLevelString): Pull the value out of the WebCoreLogging user default key.
* platform/qt/LoggingQt.cpp:
(WebCore::logLevelString): Pull the value out of the QT_WEBKIT_LOG environment variable, and then prepend
NotYetImplemented to it so that the channel will be enabled by default.
* platform/win/LoggingWin.cpp:
(WebCore::logLevelString): Pull the value out of the WebCoreLogging environment variable.

Source/WebKit/blackberry:

* Api/BlackBerryGlobal.cpp: Switch from WebCore's InitializeLogging.h to Logging.h.

Source/WebKit/efl:

* ewk/ewk_main.cpp: Switch from WebCore's InitializeLogging.h to Logging.h.

Source/WebKit/gtk:

* webkit/webkitglobals.cpp: Switch from WebCore's InitializeLogging.h to Logging.h.

Source/WebKit/mac:

* Misc/WebKitLogging.h: Declare a WEBKIT_LOG_CHANNELS macro that can be used to apply a preprocessor macro
across the set of all logging channels. Use this macro to declare the logging channels.
* Misc/WebKitLogging.m: Use WEBKIT_LOG_CHANNELS to define all of the channels. Pass the channels and the
preference value to the new WTF function that handles the initialization.
* WebView/WebPreferenceKeysPrivate.h: Remove a key that does not need to be here.
* WebView/WebView.mm: Switch from WebCore's InitializeLogging.h to Logging.h.

Source/WebKit/qt:

* WebCoreSupport/InitWebCoreQt.cpp: Switch from WebCore's InitializeLogging.h to Logging.h.

Source/WebKit/win:

* WebKitLogging.cpp: Declare a WEBKIT_LOG_CHANNELS macro that can be used to apply a preprocessor macro across
the set of all logging channels. Use this macro to declare the logging channels.
* WebKitLogging.h: Use WEBKIT_LOG_CHANNELS to define all of the channels. Pass the channels to the new WTF
function that handles the initialization. As per the previous implementation a developer needs to hard-code
their desired log level here.
* WebView.cpp: Switch from WebCore's InitializeLogging.h to Logging.h.

Source/WebKit2:

* NetworkProcess/NetworkProcess.cpp: Switch from WebCore's InitializeLogging.h to Logging.h.
* Platform/Logging.cpp: Use WEBKIT2_LOG_CHANNELS to define all of the channels.
(WebKit::initializeLogChannelsIfNecessary): Pass the channels and the log level string to the new WTF function
that handles the initialization.
(WebKit::logChannelByName): Renamed to match our naming conventions. Calls through to the new WTF function
to find a log channel rather than repeating the names of the log channels a further two times each.
(WebKit::logLevelString): Provide a no-op implementation.
* Platform/Logging.h: Declare a WEBKIT2_LOG_CHANNELS macro that can be used to apply a preprocessor macro
across the set of all logging channels. Use this macro to declare the logging channels.
* Platform/efl/LoggingEfl.cpp:
(WebKit::logLevelString): Pull the value out of the WEBKIT_DEBUG environment variable.
* Platform/gtk/LoggingGtk.cpp:
(WebKit::logLevelString): Ditto.
* Platform/mac/Logging.mac.mm:
(WebKit::logLevelString): Pull the value out of the WebKit2Logging user default key.
* Platform/qt/LoggingQt.cpp:
(WebKit::logLevelString): Pull the value out of the QT_WEBKIT_LOG environment variable.
* Shared/WebKit2Initialize.cpp: Switch from WebCore's InitializeLogging.h to Logging.h.
* UIProcess/WebContext.cpp: Switch from WebCore's InitializeLogging.h to Logging.h.

Source/WTF:

* wtf/Assertions.cpp:
(WTFLogChannelByName): Iterate over the provided array of log channels, returning the first whose name
matches case-insensitively.
(setStateOfAllChannels): Helper function to set the state of all channels to a single value.
(WTFInitializeLogChannelStatesFromString): Parse a string containing a case-insensitive, comma-separated list
of channel names to enable or disable, with the latter being prefixed by a "-".
* wtf/Assertions.h: Update the layout of WTFLogChannel to include only the state of the channel and its name.
Declare WTFLogChannelByName and WTFInitializeLogChannelStatesFromString.
* wtf/RefCountedLeakCounter.cpp: Update to the new format of WTFLogChannel.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@153736 268f45cc-cd09-0410-ab3c-d52691b4dbfc
45 files changed:
Source/WTF/ChangeLog
Source/WTF/wtf/Assertions.cpp
Source/WTF/wtf/Assertions.h
Source/WTF/wtf/RefCountedLeakCounter.cpp
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.list.am
Source/WebCore/Target.pri
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/platform/InitializeLogging.h [deleted file]
Source/WebCore/platform/Logging.cpp
Source/WebCore/platform/Logging.h
Source/WebCore/platform/blackberry/LoggingBlackBerry.cpp
Source/WebCore/platform/efl/LoggingEfl.cpp
Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp
Source/WebCore/platform/gtk/LoggingGtk.cpp
Source/WebCore/platform/mac/LoggingMac.mm
Source/WebCore/platform/qt/LoggingQt.cpp
Source/WebCore/platform/win/LoggingWin.cpp
Source/WebKit/blackberry/Api/BlackBerryGlobal.cpp
Source/WebKit/blackberry/ChangeLog
Source/WebKit/efl/ChangeLog
Source/WebKit/efl/ewk/ewk_main.cpp
Source/WebKit/gtk/ChangeLog
Source/WebKit/gtk/webkit/webkitglobals.cpp
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/Misc/WebKitLogging.h
Source/WebKit/mac/Misc/WebKitLogging.m
Source/WebKit/mac/WebView/WebPreferenceKeysPrivate.h
Source/WebKit/mac/WebView/WebView.mm
Source/WebKit/qt/ChangeLog
Source/WebKit/qt/WebCoreSupport/InitWebCoreQt.cpp
Source/WebKit/win/ChangeLog
Source/WebKit/win/WebKitLogging.cpp
Source/WebKit/win/WebKitLogging.h
Source/WebKit/win/WebView.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/NetworkProcess/NetworkProcess.cpp
Source/WebKit2/Platform/Logging.cpp
Source/WebKit2/Platform/Logging.h
Source/WebKit2/Platform/efl/LoggingEfl.cpp
Source/WebKit2/Platform/gtk/LoggingGtk.cpp
Source/WebKit2/Platform/mac/Logging.mac.mm
Source/WebKit2/Platform/qt/LoggingQt.cpp
Source/WebKit2/Shared/WebKit2Initialize.cpp
Source/WebKit2/UIProcess/WebContext.cpp