Skip to content
  • mrowe@apple.com's avatar
    Logging should be configurable using human-readable channel names rather than crazy bitmasks · e6021b96
    mrowe@apple.com authored
    <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: http://svn.webkit.org/repository/webkit/trunk@153736 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    e6021b96