WebCore/platform/gtk/LoggingGtk.cpp
changeset 0 4f2f89ce4247
equal deleted inserted replaced
-1:000000000000 0:4f2f89ce4247
       
     1 /*
       
     2  * Copyright (C) 2007 Alp Toker <alp@atoker.com>
       
     3  * Copyright (C) 2009 Gustavo Noronha Silva <gns@gnome.org>
       
     4  *
       
     5  * This library is free software; you can redistribute it and/or
       
     6  * modify it under the terms of the GNU Library General Public
       
     7  * License as published by the Free Software Foundation; either
       
     8  * version 2 of the License, or (at your option) any later version.
       
     9  *
       
    10  * This library is distributed in the hope that it will be useful,
       
    11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
       
    13  * Library General Public License for more details.
       
    14  *
       
    15  * You should have received a copy of the GNU Library General Public License
       
    16  * along with this library; see the file COPYING.LIB.  If not, write to
       
    17  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
       
    18  * Boston, MA 02110-1301, USA.
       
    19  */
       
    20 
       
    21 #include "config.h"
       
    22 #include "Logging.h"
       
    23 #include "PlatformString.h"
       
    24 
       
    25 #include <glib.h>
       
    26 #include <string.h>
       
    27 
       
    28 namespace WebCore {
       
    29 
       
    30 // Inspired by the code used by the Qt port
       
    31 
       
    32 void InitializeLoggingChannelsIfNecessary()
       
    33 {
       
    34     static bool didInitializeLoggingChannels = false;
       
    35     if (didInitializeLoggingChannels)
       
    36         return;
       
    37 
       
    38     didInitializeLoggingChannels = true;
       
    39 
       
    40     char* logEnv = getenv("WEBKIT_DEBUG");
       
    41     if (!logEnv)
       
    42         return;
       
    43 
       
    44     // we set up the logs anyway because some of our logging, such as
       
    45     // soup's is available in release builds
       
    46 #if defined(NDEBUG)
       
    47     g_warning("WEBKIT_DEBUG is not empty, but this is a release build. Notice that many log messages will only appear in a debug build.");
       
    48 #endif
       
    49 
       
    50     char** logv = g_strsplit(logEnv, " ", -1);
       
    51 
       
    52     for (int i = 0; logv[i]; i++) {
       
    53         if (WTFLogChannel* channel = getChannelFromName(logv[i]))
       
    54             channel->state = WTFLogChannelOn;
       
    55     }
       
    56 
       
    57     g_strfreev(logv);
       
    58 
       
    59     // to disable logging notImplemented set the DISABLE_NI_WARNING
       
    60     // environment variable to 1
       
    61     LogNotYetImplemented.state = WTFLogChannelOn;
       
    62 }
       
    63 
       
    64 } // namespace WebCore