Commit e6021b96 authored by mrowe@apple.com's avatar mrowe@apple.com

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: http://svn.webkit.org/repository/webkit/trunk@153736 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 6bc66d77
2013-07-26 Mark Rowe <mrowe@apple.com>
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.
* 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.
2013-08-05 Benjamin Poulain <bpoulain@apple.com>
Disable <meter> by default on iOS, it is enabled through the xconfig files
......
/*
* Copyright (C) 2003, 2006, 2007 Apple Inc. All rights reserved.
* Copyright (C) 2003, 2006, 2007, 2013 Apple Inc. All rights reserved.
* Copyright (C) 2007-2009 Torch Mobile, Inc.
* Copyright (C) 2011 University of Szeged. All rights reserved.
*
......@@ -36,6 +36,9 @@
#include "Compiler.h"
#include "OwnArrayPtr.h"
#include <wtf/StdLibExtras.h>
#include <wtf/text/CString.h>
#include <wtf/text/WTFString.h>
#include <stdio.h>
#include <stdarg.h>
......@@ -433,4 +436,48 @@ void WTFLogAlways(const char* format, ...)
va_end(args);
}
WTFLogChannel* WTFLogChannelByName(WTFLogChannel* channels[], size_t count, const char* name)
{
for (size_t i = 0; i < count; ++i) {
WTFLogChannel* channel = channels[i];
if (!strcasecmp(name, channel->name))
return channel;
}
return 0;
}
static void setStateOfAllChannels(WTFLogChannel* channels[], size_t channelCount, WTFLogChannelState state)
{
for (size_t i = 0; i < channelCount; ++i)
channels[i]->state = state;
}
void WTFInitializeLogChannelStatesFromString(WTFLogChannel* channels[], size_t count, const char* logLevel)
{
String logLevelString = logLevel;
Vector<String> components;
logLevelString.split(',', components);
for (size_t i = 0; i < components.size(); ++i) {
String component = components[i];
WTFLogChannelState logChannelState = WTFLogChannelOn;
if (component.startsWith('-')) {
logChannelState = WTFLogChannelOff;
component = component.substring(1);
}
if (equalIgnoringCase(component, "all")) {
setStateOfAllChannels(channels, count, logChannelState);
continue;
}
if (WTFLogChannel* channel = WTFLogChannelByName(channels, count, component.utf8().data()))
channel->state = logChannelState;
else
WTFLogAlways("Unknown logging channel: %s", component.utf8().data());
}
}
} // extern "C"
/*
* Copyright (C) 2003, 2006, 2007 Apple Inc. All rights reserved.
* Copyright (C) 2003, 2006, 2007, 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
......@@ -103,9 +103,8 @@ extern "C" {
typedef enum { WTFLogChannelOff, WTFLogChannelOn } WTFLogChannelState;
typedef struct {
unsigned mask;
const char *defaultName;
WTFLogChannelState state;
const char* name;
} WTFLogChannel;
WTF_EXPORT_PRIVATE void WTFReportAssertionFailure(const char* file, int line, const char* function, const char* assertion);
......@@ -116,6 +115,8 @@ WTF_EXPORT_PRIVATE void WTFReportError(const char* file, int line, const char* f
WTF_EXPORT_PRIVATE void WTFLog(WTFLogChannel*, const char* format, ...) WTF_ATTRIBUTE_PRINTF(2, 3);
WTF_EXPORT_PRIVATE void WTFLogVerbose(const char* file, int line, const char* function, WTFLogChannel*, const char* format, ...) WTF_ATTRIBUTE_PRINTF(5, 6);
WTF_EXPORT_PRIVATE void WTFLogAlways(const char* format, ...) WTF_ATTRIBUTE_PRINTF(1, 2);
WTF_EXPORT_PRIVATE WTFLogChannel* WTFLogChannelByName(WTFLogChannel*[], size_t count, const char*);
WTF_EXPORT_PRIVATE void WTFInitializeLogChannelStatesFromString(WTFLogChannel*[], size_t count, const char*);
WTF_EXPORT_PRIVATE void WTFGetBacktrace(void** stack, int* size);
WTF_EXPORT_PRIVATE void WTFReportBacktrace();
......
......@@ -39,7 +39,7 @@ void RefCountedLeakCounter::decrement() { }
#else
#define LOG_CHANNEL_PREFIX Log
static WTFLogChannel LogRefCountedLeaks = { 0x00000000, "", WTFLogChannelOn };
static WTFLogChannel LogRefCountedLeaks = { WTFLogChannelOn, "RefCountedLeaks" };
typedef HashCountedSet<const char*, PtrHash<const char*> > ReasonSet;
static ReasonSet* leakMessageSuppressionReasons;
......
2013-07-27 Mark Rowe <mrowe@apple.com>
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.
* 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.
2013-08-05 Ryosuke Niwa <rniwa@webkit.org>
Editor::updateMarkersForWordsAffectedByEditing(bool) shouldn't compute start and end of words when there are nor markers
......@@ -6066,7 +6066,6 @@ platform_sources += \
Source/WebCore/platform/HistogramSupport.cpp \
Source/WebCore/platform/HistogramSupport.h \
Source/WebCore/platform/HostWindow.h \
Source/WebCore/platform/InitializeLogging.h \
Source/WebCore/platform/KURL.cpp \
Source/WebCore/platform/KURL.h \
Source/WebCore/platform/KURLHash.h \
......
......@@ -2134,7 +2134,6 @@ HEADERS += \
platform/FileStreamClient.h \
platform/FileSystem.h \
platform/HistogramSupport.h \
platform/InitializeLogging.h \
platform/image-decoders/ImageDecoder.h \
platform/mock/DeviceMotionClientMock.h \
platform/mock/DeviceOrientationClientMock.h \
......
......@@ -3591,7 +3591,7 @@
A81872240977D3C0005826D9 /* NameNodeList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A81872190977D3C0005826D9 /* NameNodeList.cpp */; };
A81872250977D3C0005826D9 /* ChildNodeList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A818721A0977D3C0005826D9 /* ChildNodeList.cpp */; };
A8239E0009B3CF8A00B60641 /* Logging.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8239DFE09B3CF8A00B60641 /* Logging.cpp */; };
A8239E0109B3CF8A00B60641 /* Logging.h in Headers */ = {isa = PBXBuildFile; fileRef = A8239DFF09B3CF8A00B60641 /* Logging.h */; settings = {ATTRIBUTES = (); }; };
A8239E0109B3CF8A00B60641 /* Logging.h in Headers */ = {isa = PBXBuildFile; fileRef = A8239DFF09B3CF8A00B60641 /* Logging.h */; settings = {ATTRIBUTES = (Private, ); }; };
A824B4650E2EF2EA0081A7B7 /* TextRun.h in Headers */ = {isa = PBXBuildFile; fileRef = A824B4640E2EF2EA0081A7B7 /* TextRun.h */; settings = {ATTRIBUTES = (Private, ); }; };
A833C7CA0A2CF06B00D57664 /* SVGNames.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 656581E809D1508D000E61D7 /* SVGNames.cpp */; };
A833C7CC0A2CF07400D57664 /* XLinkNames.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 656581EA09D1508D000E61D7 /* XLinkNames.cpp */; };
......@@ -5386,7 +5386,6 @@
E14A94D716DFDF950068DE82 /* BlobRegistry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E14A94D616DFDF950068DE82 /* BlobRegistry.cpp */; };
E14F1C4414B5DAC600EA9009 /* HTMLFormControlElementWithState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E14F1C4214B5DAC600EA9009 /* HTMLFormControlElementWithState.cpp */; };
E14F1C4514B5DAC600EA9009 /* HTMLFormControlElementWithState.h in Headers */ = {isa = PBXBuildFile; fileRef = E14F1C4314B5DAC600EA9009 /* HTMLFormControlElementWithState.h */; settings = {ATTRIBUTES = (Private, ); }; };
E1513D4F1677EA8300149FCB /* InitializeLogging.h in Headers */ = {isa = PBXBuildFile; fileRef = E1513D4E1677EA8300149FCB /* InitializeLogging.h */; settings = {ATTRIBUTES = (Private, ); }; };
E1513D511677F08800149FCB /* NotImplemented.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1513D501677F08800149FCB /* NotImplemented.cpp */; };
E152551516FD2350003D7ADB /* WebCoreResourceHandleAsOperationQueueDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = E152551316FD234F003D7ADB /* WebCoreResourceHandleAsOperationQueueDelegate.h */; };
E152551616FD2350003D7ADB /* WebCoreResourceHandleAsOperationQueueDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = E152551416FD234F003D7ADB /* WebCoreResourceHandleAsOperationQueueDelegate.mm */; };
......@@ -12177,7 +12176,6 @@
E14A94D616DFDF950068DE82 /* BlobRegistry.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BlobRegistry.cpp; sourceTree = "<group>"; };
E14F1C4214B5DAC600EA9009 /* HTMLFormControlElementWithState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLFormControlElementWithState.cpp; sourceTree = "<group>"; };
E14F1C4314B5DAC600EA9009 /* HTMLFormControlElementWithState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLFormControlElementWithState.h; sourceTree = "<group>"; };
E1513D4E1677EA8300149FCB /* InitializeLogging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InitializeLogging.h; sourceTree = "<group>"; };
E1513D501677F08800149FCB /* NotImplemented.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NotImplemented.cpp; sourceTree = "<group>"; };
E152551316FD234F003D7ADB /* WebCoreResourceHandleAsOperationQueueDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebCoreResourceHandleAsOperationQueueDelegate.h; sourceTree = "<group>"; };
E152551416FD234F003D7ADB /* WebCoreResourceHandleAsOperationQueueDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreResourceHandleAsOperationQueueDelegate.mm; sourceTree = "<group>"; };
......@@ -19331,7 +19329,6 @@
D6FDAEF2149C06190037B1E1 /* HistogramSupport.cpp */,
D630E2AB149BF344005B2F93 /* HistogramSupport.h */,
BC3BC29B0E91AB0F00835588 /* HostWindow.h */,
E1513D4E1677EA8300149FCB /* InitializeLogging.h */,
521D46F711AEC9B100514613 /* KillRing.h */,
4306E4E514955543007F17AC /* KillRingNone.cpp */,
6593923509AE4346002C531F /* KURL.cpp */,
......@@ -22173,7 +22170,6 @@
07CE77D516712A6A00C55A47 /* InbandTextTrackPrivateClient.h in Headers */,
07367DDF172CA67F00D861B9 /* InbandTextTrackPrivateLegacyAVFObjC.h in Headers */,
DB23C2CC0A508D29002489EB /* IndentOutdentCommand.h in Headers */,
E1513D4F1677EA8300149FCB /* InitializeLogging.h in Headers */,
F3644B001119805900E0D537 /* InjectedScript.h in Headers */,
AAB6054F15874C58007B5031 /* InjectedScriptBase.h in Headers */,
AA73183F159255B900A93E6E /* InjectedScriptCanvasModule.h in Headers */,
/*
* Copyright (C) 2012 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. AND ITS CONTRIBUTORS ``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 ITS 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.
*/
#ifndef InitializeLogging_h
#define InitializeLogging_h
#if !LOG_DISABLED
namespace WebCore {
void initializeLoggingChannelsIfNecessary();
}
#endif // !LOG_DISABLED
#endif // InitializeLogging_h
/*
* Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
* Copyright (C) 2003, 2006, 2013 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -26,137 +26,38 @@
#include "config.h"
#include "Logging.h"
#include <wtf/StdLibExtras.h>
#include <wtf/text/CString.h>
#include <wtf/text/WTFString.h>
#if !LOG_DISABLED
namespace WebCore {
WTFLogChannel LogNotYetImplemented = { 0x00000001, "WebCoreLogLevel", WTFLogChannelOff };
#define DEFINE_LOG_CHANNEL(name) \
WTFLogChannel JOIN_LOG_CHANNEL_WITH_PREFIX(LOG_CHANNEL_PREFIX, name) = { WTFLogChannelOff, #name };
WEBCORE_LOG_CHANNELS(DEFINE_LOG_CHANNEL)
WTFLogChannel LogFrames = { 0x00000010, "WebCoreLogLevel", WTFLogChannelOff };
WTFLogChannel LogLoading = { 0x00000020, "WebCoreLogLevel", WTFLogChannelOff };
WTFLogChannel LogPopupBlocking = { 0x00000040, "WebCoreLogLevel", WTFLogChannelOff };
WTFLogChannel LogEvents = { 0x00000080, "WebCoreLogLevel", WTFLogChannelOff };
#define LOG_CHANNEL_ADDRESS(name) &JOIN_LOG_CHANNEL_WITH_PREFIX(LOG_CHANNEL_PREFIX, name),
WTFLogChannel* logChannels[] = {
WEBCORE_LOG_CHANNELS(LOG_CHANNEL_ADDRESS)
};
WTFLogChannel LogEditing = { 0x00000100, "WebCoreLogLevel", WTFLogChannelOff };
WTFLogChannel LogLiveConnect = { 0x00000200, "WebCoreLogLevel", WTFLogChannelOff };
WTFLogChannel LogIconDatabase = { 0x00000400, "WebCoreLogLevel", WTFLogChannelOff };
WTFLogChannel LogSQLDatabase = { 0x00000800, "WebCoreLogLevel", WTFLogChannelOff };
size_t logChannelCount = WTF_ARRAY_LENGTH(logChannels);
WTFLogChannel LogSpellingAndGrammar ={ 0x00001000, "WebCoreLogLevel", WTFLogChannelOff };
WTFLogChannel LogBackForward = { 0x00002000, "WebCoreLogLevel", WTFLogChannelOff };
WTFLogChannel LogHistory = { 0x00004000, "WebCoreLogLevel", WTFLogChannelOff };
WTFLogChannel LogPageCache = { 0x00008000, "WebCoreLogLevel", WTFLogChannelOff };
WTFLogChannel LogPlatformLeaks = { 0x00010000, "WebCoreLogLevel", WTFLogChannelOff };
WTFLogChannel LogResourceLoading = { 0x00020000, "WebCoreLogLevel", WTFLogChannelOff };
WTFLogChannel LogAnimations = { 0x00040000, "WebCoreLogLevel", WTFLogChannelOff };
WTFLogChannel LogNetwork = { 0x00100000, "WebCoreLogLevel", WTFLogChannelOff };
WTFLogChannel LogFTP = { 0x00200000, "WebCoreLogLevel", WTFLogChannelOff };
WTFLogChannel LogThreading = { 0x00400000, "WebCoreLogLevel", WTFLogChannelOff };
WTFLogChannel LogStorageAPI = { 0x00800000, "WebCoreLogLevel", WTFLogChannelOff };
WTFLogChannel LogMedia = { 0x01000000, "WebCoreLogLevel", WTFLogChannelOff };
WTFLogChannel LogPlugins = { 0x02000000, "WebCoreLogLevel", WTFLogChannelOff };
WTFLogChannel LogArchives = { 0x04000000, "WebCoreLogLevel", WTFLogChannelOff };
WTFLogChannel LogProgress = { 0x08000000, "WebCoreLogLevel", WTFLogChannelOff };
WTFLogChannel LogFileAPI = { 0x10000000, "WebCoreLogLevel", WTFLogChannelOff };
WTFLogChannel LogWebAudio = { 0x20000000, "WebCoreLogLevel", WTFLogChannelOff };
WTFLogChannel LogCompositing = { 0x40000000, "WebCoreLogLevel", WTFLogChannelOff };
WTFLogChannel LogGamepad = { 0x80000000, "WebCoreLogLevel", WTFLogChannelOff };
WTFLogChannel* getChannelFromName(const String& channelName)
WTFLogChannel* logChannelByName(const String& name)
{
if (!(channelName.length() >= 2))
return 0;
if (equalIgnoringCase(channelName, String("BackForward")))
return &LogBackForward;
if (equalIgnoringCase(channelName, String("Editing")))
return &LogEditing;
if (equalIgnoringCase(channelName, String("Events")))
return &LogEvents;
if (equalIgnoringCase(channelName, String("Frames")))
return &LogFrames;
if (equalIgnoringCase(channelName, String("FTP")))
return &LogFTP;
if (equalIgnoringCase(channelName, String("History")))
return &LogHistory;
if (equalIgnoringCase(channelName, String("IconDatabase")))
return &LogIconDatabase;
if (equalIgnoringCase(channelName, String("Loading")))
return &LogLoading;
if (equalIgnoringCase(channelName, String("Media")))
return &LogMedia;
if (equalIgnoringCase(channelName, String("Network")))
return &LogNetwork;
if (equalIgnoringCase(channelName, String("NotYetImplemented")))
return &LogNotYetImplemented;
if (equalIgnoringCase(channelName, String("PageCache")))
return &LogPageCache;
if (equalIgnoringCase(channelName, String("PlatformLeaks")))
return &LogPlatformLeaks;
if (equalIgnoringCase(channelName, String("ResourceLoading")))
return &LogResourceLoading;
if (equalIgnoringCase(channelName, String("Animations")))
return &LogAnimations;
if (equalIgnoringCase(channelName, String("Plugins")))
return &LogPlugins;
if (equalIgnoringCase(channelName, String("PopupBlocking")))
return &LogPopupBlocking;
if (equalIgnoringCase(channelName, String("Progress")))
return &LogProgress;
if (equalIgnoringCase(channelName, String("SpellingAndGrammar")))
return &LogSpellingAndGrammar;
if (equalIgnoringCase(channelName, String("SQLDatabase")))
return &LogSQLDatabase;
if (equalIgnoringCase(channelName, String("StorageAPI")))
return &LogStorageAPI;
if (equalIgnoringCase(channelName, String("LiveConnect")))
return &LogLiveConnect;
if (equalIgnoringCase(channelName, String("Threading")))
return &LogThreading;
if (equalIgnoringCase(channelName, String("FileAPI")))
return &LogFileAPI;
if (equalIgnoringCase(channelName, String("WebAudio")))
return &LogWebAudio;
if (equalIgnoringCase(channelName, String("Compositing")))
return &LogCompositing;
return WTFLogChannelByName(logChannels, logChannelCount, name.utf8().data());
}
if (equalIgnoringCase(channelName, String("Gamepad")))
return &LogGamepad;
void initializeLoggingChannelsIfNecessary()
{
static bool haveInitializedLoggingChannels = false;
if (haveInitializedLoggingChannels)
return;
haveInitializedLoggingChannels = true;
return 0;
WTFInitializeLogChannelStatesFromString(logChannels, logChannelCount, logLevelString().utf8().data());
}
}
......
/*
* Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
* Copyright (C) 2003, 2006, 2013 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -37,36 +37,49 @@
namespace WebCore {
extern WTFLogChannel LogNotYetImplemented;
extern WTFLogChannel LogFrames;
extern WTFLogChannel LogLoading;
extern WTFLogChannel LogPopupBlocking;
extern WTFLogChannel LogEvents;
extern WTFLogChannel LogEditing;
extern WTFLogChannel LogLiveConnect;
extern WTFLogChannel LogIconDatabase;
extern WTFLogChannel LogSQLDatabase;
extern WTFLogChannel LogSpellingAndGrammar;
extern WTFLogChannel LogBackForward;
extern WTFLogChannel LogHistory;
extern WTFLogChannel LogPageCache;
extern WTFLogChannel LogPlatformLeaks;
extern WTFLogChannel LogResourceLoading;
extern WTFLogChannel LogAnimations;
extern WTFLogChannel LogNetwork;
extern WTFLogChannel LogFTP;
extern WTFLogChannel LogThreading;
extern WTFLogChannel LogStorageAPI;
extern WTFLogChannel LogMedia;
extern WTFLogChannel LogPlugins;
extern WTFLogChannel LogArchives;
extern WTFLogChannel LogProgress;
extern WTFLogChannel LogFileAPI;
extern WTFLogChannel LogWebAudio;
extern WTFLogChannel LogCompositing;
extern WTFLogChannel LogGamepad;
#define WEBCORE_LOG_CHANNELS(M) \
M(Animations) \
M(Archives) \
M(BackForward) \
M(Compositing) \
M(Editing) \
M(Events) \
M(FTP) \
M(FileAPI) \
M(Frames) \
M(Gamepad) \
M(History) \
M(IconDatabase) \
M(LiveConnect) \
M(Loading) \
M(Media) \
M(Network) \
M(NotYetImplemented) \
M(PageCache) \
M(PlatformLeaks) \
M(Plugins) \
M(PopupBlocking) \
M(Progress) \
M(ResourceLoading) \
M(SQLDatabase) \
M(SpellingAndGrammar) \
M(StorageAPI) \
M(Threading) \
M(WebAudio) \
WTFLogChannel* getChannelFromName(const String& channelName);
#define DECLARE_LOG_CHANNEL(name) \
extern WTFLogChannel JOIN_LOG_CHANNEL_WITH_PREFIX(LOG_CHANNEL_PREFIX, name);
WEBCORE_LOG_CHANNELS(DECLARE_LOG_CHANNEL)
#undef DECLARE_LOG_CHANNEL
extern WTFLogChannel* logChannels[];
extern size_t logChannelCount;
String logLevelString();
WTFLogChannel* logChannelByName(const String&);
void initializeLoggingChannelsIfNecessary();
}
#endif // !LOG_DISABLED
......
/*
* Copyright (C) 2009, 2010, 2011 Research In Motion Limited. All rights reserved.
* Copyright (C) 2013 Apple Inc. All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -19,41 +20,15 @@
#include "config.h"
#include "Logging.h"
#include "InitializeLogging.h"
#if !LOG_DISABLED
#include <wtf/text/WTFString.h>
namespace WebCore {
static inline void initializeWithUserDefault(WTFLogChannel& channel, bool enabled)
{
if (enabled)
channel.state = WTFLogChannelOn;
else
channel.state = WTFLogChannelOff;
}
void initializeLoggingChannelsIfNecessary()
String logLevelString()
{
static bool haveInitializedLoggingChannels = false;
if (haveInitializedLoggingChannels)
return;
haveInitializedLoggingChannels = true;
String logEnv = getenv("WEBKIT_DEBUG");
if (logEnv.isEmpty())
return;
Vector<String> logv;
logEnv.split(" ", logv);
Vector<String>::const_iterator it = logv.begin();
for (; it != logv.end(); ++it) {
if (WTFLogChannel* channel = getChannelFromName(*it))
channel->state = WTFLogChannelOn;
}
return getenv("WEBKIT_DEBUG");
}
} // namespace WebCore
......
......@@ -3,6 +3,7 @@
* Copyright (C) 2008 INdT - Instituto Nokia de Tecnologia
* Copyright (C) 2009-2010 ProFUSION embedded systems
* Copyright (C) 2009-2010 Samsung Electronics
* Copyright (C) 2013 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
......@@ -21,47 +22,28 @@
*/
#include "config.h"
#include "InitializeLogging.h"
#include "Logging.h"
#if !LOG_DISABLED
#include <Eina.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
void initializeLoggingChannelsIfNecessary()
String logLevelString()
{
static bool didInitializeLoggingChannels = false;
if (didInitializeLoggingChannels)
return;
didInitializeLoggingChannels = true;
char* logEnv = getenv("WEBKIT_DEBUG");
if (!logEnv)
return;
return emptyString();
#if defined(NDEBUG)
EINA_LOG_WARN("WEBKIT_DEBUG is not empty, but this is a release build. Notice that many log messages will only appear in a debug build.");
#endif
char** logv = eina_str_split(logEnv, ",", -1);
EINA_SAFETY_ON_NULL_RETURN(logv);
for (int i = 0; logv[i]; i++) {
if (WTFLogChannel* channel = getChannelFromName(logv[i]))
channel->state = WTFLogChannelOn;
}
free(*logv);
free(logv);
// To disable logging notImplemented set the DISABLE_NI_WARNING
// environment variable to 1.
LogNotYetImplemented.state = WTFLogChannelOn;
// To disable logging notImplemented set the DISABLE_NI_WARNING environment variable to 1.
String logLevel = "NotYetImplemented,";
logLevel.append(logEnv);
return logLevel;
}
}
...