upload webkit/tizen 2.0_beta source.
[framework/web/webkit-efl.git] / Source / WebKit2 / Platform / Logging.cpp
1 /*
2  * Copyright (C) 2010 Apple Inc. All rights reserved.
3  * Copyright (C) 2011 Samsung Electronics
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
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  *
14  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
15  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
18  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
24  * THE POSSIBILITY OF SUCH DAMAGE.
25  */
26
27 #include "config.h"
28 #include "Logging.h"
29
30 #if !LOG_DISABLED
31
32 namespace WebKit {
33
34 WTFLogChannel LogSessionState = { 0x00000001, "WebKit2LogLevel", WTFLogChannelOff };
35 WTFLogChannel LogContextMenu  = { 0x00000002, "WebKit2LogLevel", WTFLogChannelOff };
36 WTFLogChannel LogTextInput    = { 0x00000004, "WebKit2LogLevel", WTFLogChannelOff };
37 WTFLogChannel LogView         = { 0x00000008, "WebKit2LogLevel", WTFLogChannelOff };
38 WTFLogChannel LogIconDatabase = { 0x00000010, "WebKit2LogLevel", WTFLogChannelOff };
39 WTFLogChannel LogKeyHandling  = { 0x00000020, "WebKit2LogLevel", WTFLogChannelOff };
40
41 #if !PLATFORM(MAC) && !PLATFORM(GTK)
42 void initializeLogChannel(WTFLogChannel* channel)
43 {
44     // FIXME: Each platform will need to define their own initializeLogChannel().
45 }
46 #endif
47
48 #if PLATFORM(GTK)
49 WTFLogChannel* getChannelFromName(const String& channelName)
50 {
51     if (!(channelName.length() >= 2))
52         return 0;
53
54     if (equalIgnoringCase(channelName, String("SessionState")))
55         return &LogSessionState;
56
57     if (equalIgnoringCase(channelName, String("ContextMenu")))
58         return &LogContextMenu;
59
60     if (equalIgnoringCase(channelName, String("TextInput")))
61         return &LogTextInput;
62
63     if (equalIgnoringCase(channelName, String("View")))
64         return &LogView;
65
66     if (equalIgnoringCase(channelName, String("IconDatabase")))
67         return &LogIconDatabase;
68
69     if (equalIgnoringCase(channelName, String("KeyHandling")))
70         return &LogKeyHandling;
71
72     return 0;
73 }
74 #endif
75
76 void initializeLogChannelsIfNecessary()
77 {
78     static bool haveInitializedLogChannels = false;
79     if (haveInitializedLogChannels)
80         return;
81     haveInitializedLogChannels = true;
82
83     initializeLogChannel(&LogContextMenu);
84     initializeLogChannel(&LogIconDatabase);
85     initializeLogChannel(&LogKeyHandling);
86     initializeLogChannel(&LogSessionState);
87     initializeLogChannel(&LogTextInput);
88     initializeLogChannel(&LogView);
89 }
90
91 } // namespace WebKit
92
93 #endif // LOG_DISABLED