• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 2005, 2007 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1.  Redistributions of source code must retain the above copyright
9 *     notice, this list of conditions and the following disclaimer.
10 * 2.  Redistributions in binary form must reproduce the above copyright
11 *     notice, this list of conditions and the following disclaimer in the
12 *     documentation and/or other materials provided with the distribution.
13 * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
14 *     its contributors may be used to endorse or promote products derived
15 *     from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#import "WebKitLogging.h"
30
31WTFLogChannel WebKitLogTextInput =              { 0x00000010, "WebKitLogLevel", WTFLogChannelOff };
32WTFLogChannel WebKitLogTiming =                 { 0x00000020, "WebKitLogLevel", WTFLogChannelOff };
33WTFLogChannel WebKitLogLoading =                { 0x00000040, "WebKitLogLevel", WTFLogChannelOff };
34WTFLogChannel WebKitLogFontCache =              { 0x00000100, "WebKitLogLevel", WTFLogChannelOff };
35WTFLogChannel WebKitLogFontSubstitution =       { 0x00000200, "WebKitLogLevel", WTFLogChannelOff };
36WTFLogChannel WebKitLogDownload =               { 0x00000800, "WebKitLogLevel", WTFLogChannelOff };
37WTFLogChannel WebKitLogDocumentLoad =           { 0x00001000, "WebKitLogLevel", WTFLogChannelOff };
38WTFLogChannel WebKitLogPlugins =                { 0x00002000, "WebKitLogLevel", WTFLogChannelOff };
39WTFLogChannel WebKitLogEvents =                 { 0x00010000, "WebKitLogLevel", WTFLogChannelOff };
40WTFLogChannel WebKitLogView =                   { 0x00020000, "WebKitLogLevel", WTFLogChannelOff };
41WTFLogChannel WebKitLogRedirect =               { 0x00040000, "WebKitLogLevel", WTFLogChannelOff };
42WTFLogChannel WebKitLogPageCache =              { 0x00080000, "WebKitLogLevel", WTFLogChannelOff };
43WTFLogChannel WebKitLogCacheSizes =             { 0x00100000, "WebKitLogLevel", WTFLogChannelOff };
44WTFLogChannel WebKitLogFormDelegate =           { 0x00200000, "WebKitLogLevel", WTFLogChannelOff };
45WTFLogChannel WebKitLogFileDatabaseActivity =   { 0x00400000, "WebKitLogLevel", WTFLogChannelOff };
46WTFLogChannel WebKitLogHistory =                { 0x00800000, "WebKitLogLevel", WTFLogChannelOff };
47WTFLogChannel WebKitLogBindings =               { 0x01000000, "WebKitLogLevel", WTFLogChannelOff };
48WTFLogChannel WebKitLogFontSelection =          { 0x02000000, "WebKitLogLevel", WTFLogChannelOff };
49WTFLogChannel WebKitLogEncoding =               { 0x04000000, "WebKitLogLevel", WTFLogChannelOff };
50WTFLogChannel WebKitLogLiveConnect =            { 0x08000000, "WebKitLogLevel", WTFLogChannelOff };
51WTFLogChannel WebKitLogBackForward =            { 0x10000000, "WebKitLogLevel", WTFLogChannelOff };
52WTFLogChannel WebKitLogProgress =               { 0x20000000, "WebKitLogLevel", WTFLogChannelOff };
53WTFLogChannel WebKitLogPluginEvents =           { 0x40000000, "WebKitLogLevel", WTFLogChannelOff };
54WTFLogChannel WebKitLogIconDatabase =           { 0x80000000, "WebKitLogLevel", WTFLogChannelOff };
55
56static void initializeLogChannel(WTFLogChannel *channel)
57{
58    channel->state = WTFLogChannelOff;
59    NSString *logLevelString = [[NSUserDefaults standardUserDefaults] objectForKey:[NSString stringWithUTF8String:channel->defaultName]];
60    if (logLevelString) {
61        unsigned logLevel;
62        if (![[NSScanner scannerWithString:logLevelString] scanHexInt:&logLevel])
63            NSLog(@"unable to parse hex value for %s (%@), logging is off", channel->defaultName, logLevelString);
64        if ((logLevel & channel->mask) == channel->mask)
65            channel->state = WTFLogChannelOn;
66    }
67}
68
69void WebKitInitializeLoggingChannelsIfNecessary()
70{
71    static bool haveInitializedLoggingChannels = false;
72    if (haveInitializedLoggingChannels)
73        return;
74    haveInitializedLoggingChannels = true;
75
76    initializeLogChannel(&WebKitLogTiming);
77    initializeLogChannel(&WebKitLogLoading);
78    initializeLogChannel(&WebKitLogFontCache);
79    initializeLogChannel(&WebKitLogFontSubstitution);
80    initializeLogChannel(&WebKitLogDownload);
81    initializeLogChannel(&WebKitLogDocumentLoad);
82    initializeLogChannel(&WebKitLogPlugins);
83    initializeLogChannel(&WebKitLogEvents);
84    initializeLogChannel(&WebKitLogView);
85    initializeLogChannel(&WebKitLogRedirect);
86    initializeLogChannel(&WebKitLogPageCache);
87    initializeLogChannel(&WebKitLogCacheSizes);
88    initializeLogChannel(&WebKitLogFormDelegate);
89    initializeLogChannel(&WebKitLogFileDatabaseActivity);
90    initializeLogChannel(&WebKitLogHistory);
91    initializeLogChannel(&WebKitLogBindings);
92    initializeLogChannel(&WebKitLogFontSelection);
93    initializeLogChannel(&WebKitLogEncoding);
94    initializeLogChannel(&WebKitLogLiveConnect);
95    initializeLogChannel(&WebKitLogBackForward);
96    initializeLogChannel(&WebKitLogProgress);
97    initializeLogChannel(&WebKitLogPluginEvents);
98    initializeLogChannel(&WebKitLogIconDatabase);
99    initializeLogChannel(&WebKitLogTextInput);
100}
101
102void ReportDiscardedDelegateException(SEL delegateSelector, id exception)
103{
104    if ([exception isKindOfClass:[NSException class]])
105        NSLog(@"*** WebKit discarded an uncaught exception in the %s delegate: <%@> %@",
106            sel_getName(delegateSelector), [exception name], [exception reason]);
107    else
108        NSLog(@"*** WebKit discarded an uncaught exception in the %s delegate: %@",
109            sel_getName(delegateSelector), exception);
110}
111