Changeset 41520 in webkit


Ignore:
Timestamp:
Mar 8, 2009 12:35:54 PM (15 years ago)
Author:
kov@webkit.org
Message:

2009-03-08 Gustavo Noronha Silva <Gustavo Noronha Silva>

Reviewed by Holger Freyther.

Implement proper logging for the GTK+ port, inspired by the one in
Qt. We use the WEBKIT_DEBUG environment variable which was already
being used to decide whether to setup a logger for soup or not.

  • platform/gtk/LoggingGtk.cpp: (WebCore::getChannelFromName): (WebCore::InitializeLoggingChannelsIfNecessary):
  • platform/network/soup/ResourceHandleSoup.cpp: (WebCore::ensureSessionIsInitialized):
Location:
trunk/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r41517 r41520  
     12009-03-08  Gustavo Noronha Silva  <gns@gnome.org>
     2
     3        Reviewed by Holger Freyther.
     4
     5        Implement proper logging for the GTK+ port, inspired by the one in
     6        Qt. We use the WEBKIT_DEBUG environment variable which was already
     7        being used to decide whether to setup a logger for soup or not.
     8
     9        * platform/gtk/LoggingGtk.cpp:
     10        (WebCore::getChannelFromName):
     11        (WebCore::InitializeLoggingChannelsIfNecessary):
     12        * platform/network/soup/ResourceHandleSoup.cpp:
     13        (WebCore::ensureSessionIsInitialized):
     14
    1152009-03-07  Dan Bernstein  <mitz@apple.com>
    216
  • trunk/WebCore/platform/gtk/LoggingGtk.cpp

    r29663 r41520  
    11/*
    22 * Copyright (C) 2007 Alp Toker <alp@atoker.com>
     3 * Copyright (C) 2009 Gustavo Noronha Silva <gns@gnome.org>
    34 *
    45 * This library is free software; you can redistribute it and/or
     
    2122#include "Logging.h"
    2223
     24#include <glib.h>
     25#include <string.h>
     26
    2327namespace WebCore {
     28
     29// Inspired by the code used by the Qt port
     30
     31static WTFLogChannel* getChannelFromName(const char* channelName)
     32{
     33    if (strlen(channelName) < 3)
     34        return 0;
     35
     36    if (!g_ascii_strcasecmp(channelName, "BackForward"))
     37        return &LogBackForward;
     38    if (!g_ascii_strcasecmp(channelName, "Editing"))
     39        return &LogEditing;
     40    if (!g_ascii_strcasecmp(channelName, "Events"))
     41        return &LogEvents;
     42    if (!g_ascii_strcasecmp(channelName, "Frames"))
     43        return &LogFrames;
     44    if (!g_ascii_strcasecmp(channelName, "FTP"))
     45        return &LogFTP;
     46    if (!g_ascii_strcasecmp(channelName, "History"))
     47        return &LogHistory;
     48    if (!g_ascii_strcasecmp(channelName, "IconDatabase"))
     49        return &LogIconDatabase;
     50    if (!g_ascii_strcasecmp(channelName, "Loading"))
     51        return &LogLoading;
     52    if (!g_ascii_strcasecmp(channelName, "Media"))
     53        return &LogMedia;
     54    if (!g_ascii_strcasecmp(channelName, "Network"))
     55        return &LogNetwork;
     56    if (!g_ascii_strcasecmp(channelName, "NotYetImplemented"))
     57        return &LogNotYetImplemented;
     58    if (!g_ascii_strcasecmp(channelName, "PageCache"))
     59        return &LogPageCache;
     60    if (!g_ascii_strcasecmp(channelName, "PlatformLeaks"))
     61        return &LogPlatformLeaks;
     62    if (!g_ascii_strcasecmp(channelName, "Plugin"))
     63        return &LogPlugin;
     64    if (!g_ascii_strcasecmp(channelName, "PopupBlocking"))
     65        return &LogPopupBlocking;
     66    if (!g_ascii_strcasecmp(channelName, "SpellingAndGrammar"))
     67        return &LogSpellingAndGrammar;
     68    if (!g_ascii_strcasecmp(channelName, "SQLDatabase"))
     69        return &LogSQLDatabase;
     70    if (!g_ascii_strcasecmp(channelName, "StorageAPI"))
     71        return &LogStorageAPI;
     72    if (!g_ascii_strcasecmp(channelName, "TextConversion"))
     73        return &LogTextConversion;
     74    if (!g_ascii_strcasecmp(channelName, "Threading"))
     75        return &LogThreading;
     76
     77    return 0;
     78}
    2479
    2580void InitializeLoggingChannelsIfNecessary()
    2681{
    27     // FIXME: Add a way for the user to specify which
    28     // logs he/she would like turned on.
     82    static bool didInitializeLoggingChannels = false;
     83    if (didInitializeLoggingChannels)
     84        return;
     85
     86    didInitializeLoggingChannels = true;
     87
     88    char* logEnv = getenv("WEBKIT_DEBUG");
     89    if (!logEnv)
     90        return;
     91
     92    // we set up the logs anyway because some of our logging, such as
     93    // soup's is available in release builds
     94#if defined(NDEBUG)
     95    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.");
     96#endif
     97
     98    char** logv = g_strsplit(logEnv, " ", -1);
     99
     100    for (int i = 0; logv[i]; i++) {
     101        WTFLogChannel* channel = getChannelFromName(logv[i]);
     102        if (!channel)
     103            continue;
     104        channel->state = WTFLogChannelOn;
     105    }
     106
     107    g_strfreev(logv);
     108
     109    // to disable logging notImplemented set the DISABLE_NI_WARNING
     110    // environment variable to 1
    29111    LogNotYetImplemented.state = WTFLogChannelOn;
    30112}
  • trunk/WebCore/platform/network/soup/ResourceHandleSoup.cpp

    r41483 r41520  
    3434#include "Frame.h"
    3535#include "HTTPParsers.h"
     36#include "Logging.h"
    3637#include "MIMETypeRegistry.h"
    3738#include "NotImplemented.h"
     
    402403        setDefaultCookieJar(jar);
    403404
    404     const char* webkitDebug = g_getenv("WEBKIT_DEBUG");
    405     if (!soup_session_get_feature(session, SOUP_TYPE_LOGGER)
    406         && webkitDebug && !strcmp(webkitDebug, "network")) {
     405    if (!soup_session_get_feature(session, SOUP_TYPE_LOGGER) && LogNetwork.state == WTFLogChannelOn) {
    407406        SoupLogger* logger = soup_logger_new(static_cast<SoupLoggerLogLevel>(SOUP_LOGGER_LOG_BODY), -1);
    408407        soup_logger_attach(logger, session);
Note: See TracChangeset for help on using the changeset viewer.