⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 283469 in webkit


Ignore:
Timestamp:
Oct 3, 2021, 10:19:59 AM (5 years ago)
Author:
basuke.suzuki@sony.com
Message:

Enable release log to stderr
https://bugs.webkit.org/show_bug.cgi?id=230725
<rdar://problem/83740529>

Reviewed by Michael Catanzaro.

.:

Introduced new flags, USE_LOG_STDERR for release logging to stderr.

  • Source/cmake/WebKitFeatures.cmake:

Source/WebCore:

SQLiteDatabase uses hard-coded %{public} format specifiers. Replace them with defined
macro.

No new tests because there is no behavior change.

  • platform/sql/SQLiteDatabase.cpp:

(WebCore::SQLiteDatabase::close):
(WebCore::SQLiteDatabase::prepareStatementSlow):
(WebCore::SQLiteDatabase::prepareStatement):
(WebCore::SQLiteDatabase::prepareHeapStatementSlow):
(WebCore::SQLiteDatabase::prepareHeapStatement):

Source/WTF:

Define new compiler definitions, USE_LOG_STDERR for release logging. We don't have
modern logging backend so that dumping out to stdout/stderr is still very valuable.

  • wtf/Assertions.cpp:
  • wtf/Assertions.h:
  • wtf/Logger.h:

(WTF::Logger::log):
(WTF::Logger::logVerbose):

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r283436 r283469  
     12021-10-03  Basuke Suzuki  <basuke.suzuki@sony.com>
     2
     3        Enable release log to stderr
     4        https://bugs.webkit.org/show_bug.cgi?id=230725
     5        <rdar://problem/83740529>
     6
     7        Reviewed by Michael Catanzaro.
     8
     9        Introduced new flags, USE_LOG_STDERR for release logging to stderr.
     10
     11        * Source/cmake/WebKitFeatures.cmake:
     12
    1132021-10-02  Philippe Normand  <pnormand@igalia.com>
    214
  • trunk/Source/WTF/ChangeLog

    r283437 r283469  
     12021-10-03  Basuke Suzuki  <basuke.suzuki@sony.com>
     2
     3        Enable release log to stderr
     4        https://bugs.webkit.org/show_bug.cgi?id=230725
     5        <rdar://problem/83740529>
     6
     7        Reviewed by Michael Catanzaro.
     8
     9        Define new compiler definitions, USE_LOG_STDERR for release logging. We don't have
     10        modern logging backend so that dumping out to stdout/stderr is still very valuable.
     11
     12        * wtf/Assertions.cpp:
     13        * wtf/Assertions.h:
     14        * wtf/Logger.h:
     15        (WTF::Logger::log):
     16        (WTF::Logger::logVerbose):
     17
    1182021-10-02  Philippe Normand  <pnormand@igalia.com>
    219
  • trunk/Source/WTF/wtf/Assertions.cpp

    r278474 r283469  
    6060#endif
    6161
    62 #if USE(JOURNALD)
     62#if !RELEASE_LOG_DISABLED && !USE(OS_LOG)
    6363#include <wtf/StringPrintStream.h>
    6464#endif
     
    602602            else
    603603                os_log(channel->osLogChannel, "%-3d %p", frameNumber, stackFrame);
    604 #elif USE(JOURNALD)
     604#else
    605605            StringPrintStream out;
    606606            if (demangled && demangled->demangledName())
     
    610610            else
    611611                out.printf("%-3d %p", frameNumber, stackFrame);
     612#if USE(JOURNALD)
    612613            sd_journal_send("WEBKIT_SUBSYSTEM=%s", channel->subsystem, "WEBKIT_CHANNEL=%s", channel->name, "MESSAGE=%s", out.toCString().data(), nullptr);
     614#else
     615            fprintf(stderr, "[%s:%s:-] %s\n", channel->subsystem, channel->name, out.toCString().data());
     616#endif
    613617#endif
    614618        }
  • trunk/Source/WTF/wtf/Assertions.h

    r280795 r283469  
    9696#endif
    9797
    98 #ifndef RELEASE_LOG_DISABLED
     98#if ENABLE(RELEASE_LOG)
     99#define RELEASE_LOG_DISABLED 0
     100#else
    99101#define RELEASE_LOG_DISABLED !(USE(OS_LOG) || USE(JOURNALD))
    100102#endif
     
    164166#if !RELEASE_LOG_DISABLED
    165167    const char* subsystem;
    166 #endif
    167 #if USE(OS_LOG) && !RELEASE_LOG_DISABLED
     168#if USE(OS_LOG)
    168169    __unsafe_unretained os_log_t osLogChannel;
     170#endif
    169171#endif
    170172} WTFLogChannel;
     
    179181#elif PLATFORM(WPE)
    180182#define LOG_CHANNEL_WEBKIT_SUBSYSTEM "WPEWebKit"
     183#elif PLATFORM(PLAYSTATION)
     184#define LOG_CHANNEL_WEBKIT_SUBSYSTEM "SceNKWebKit"
    181185#else
    182186#define LOG_CHANNEL_WEBKIT_SUBSYSTEM "com.apple.WebKit"
     
    190194#define DEFINE_LOG_CHANNEL_WITH_DETAILS(name, initialState, level, subsystem) \
    191195    WTFLogChannel LOG_CHANNEL(name) = { initialState, #name, level };
    192 #endif
    193 #if USE(OS_LOG) && !RELEASE_LOG_DISABLED
     196#elif USE(OS_LOG)
    194197#define DEFINE_LOG_CHANNEL_WITH_DETAILS(name, initialState, level, subsystem) \
    195198    WTFLogChannel LOG_CHANNEL(name) = { initialState, #name, level, subsystem, OS_LOG_DEFAULT };
    196 #endif
    197 #if USE(JOURNALD) && !RELEASE_LOG_DISABLED
     199#else
    198200#define DEFINE_LOG_CHANNEL_WITH_DETAILS(name, initialState, level, subsystem) \
    199201    WTFLogChannel LOG_CHANNEL(name) = { initialState, #name, level, subsystem };
     
    529531
    530532#if RELEASE_LOG_DISABLED
     533
    531534#define PUBLIC_LOG_STRING "s"
    532535#define PRIVATE_LOG_STRING "s"
     
    544547
    545548#define RELEASE_LOG_STACKTRACE(channel) ((void)0)
    546 #endif
    547 
    548 #if USE(OS_LOG) && !RELEASE_LOG_DISABLED
     549
     550#elif USE(OS_LOG)
     551
    549552#define PUBLIC_LOG_STRING "{public}s"
    550553#define PRIVATE_LOG_STRING "{private}s"
     
    562565        os_log(LOG_CHANNEL(channel).osLogChannel, __VA_ARGS__); \
    563566} while (0)
    564 #endif
    565 
    566 #if USE(JOURNALD) && !RELEASE_LOG_DISABLED
     567
     568#elif USE(JOURNALD)
     569
    567570#define PUBLIC_LOG_STRING "s"
    568571#define PRIVATE_LOG_STRING "s"
     
    588591        SD_JOURNAL_SEND(channel, LOG_INFO, __FILE__, _STRINGIFY(__LINE__), __func__, __VA_ARGS__); \
    589592} while (0)
     593
     594#else
     595
     596#define PUBLIC_LOG_STRING "s"
     597#define PRIVATE_LOG_STRING "s"
     598#define LOGF(channel, priority, fmt, ...) do { \
     599    auto& logChannel = LOG_CHANNEL(channel); \
     600    if (logChannel.state != WTFLogChannelState::Off) \
     601        fprintf(stderr, "[%s:%s:%i] " fmt "\n", logChannel.subsystem, logChannel.name, priority, ##__VA_ARGS__); \
     602} while (0)
     603
     604#define RELEASE_LOG(channel, ...) LOGF(channel, 4, __VA_ARGS__)
     605#define RELEASE_LOG_ERROR(channel, ...) LOGF(channel, 1, __VA_ARGS__)
     606#define RELEASE_LOG_FAULT(channel, ...) LOGF(channel, 2, __VA_ARGS__)
     607#define RELEASE_LOG_INFO(channel, ...) LOGF(channel, 3, __VA_ARGS__)
     608
     609#define RELEASE_LOG_WITH_LEVEL(channel, logLevel, ...) do { \
     610    if (LOG_CHANNEL(channel).level >= (logLevel)) \
     611        LOGF(channel, logLevel, __VA_ARGS__); \
     612} while (0)
     613
     614#define RELEASE_LOG_WITH_LEVEL_IF(isAllowed, channel, logLevel, ...) do { \
     615    if ((isAllowed) && LOG_CHANNEL(channel).level >= (logLevel)) \
     616        LOGF(channel, logLevel, __VA_ARGS__); \
     617} while (0)
     618
    590619#endif
    591620
  • trunk/Source/WTF/wtf/Logger.h

    r277967 r283469  
    2626#pragma once
    2727
     28#include <wtf/Assertions.h>
    2829#include <wtf/Lock.h>
    2930#include <wtf/ThreadSafeRefCounted.h>
     
    312313#if RELEASE_LOG_DISABLED
    313314        WTFLog(&channel, "%s", logMessage.utf8().data());
    314 #endif
    315 #if USE(OS_LOG) && !RELEASE_LOG_DISABLED
     315#elif USE(OS_LOG)
    316316        os_log(channel.osLogChannel, "%{public}s", logMessage.utf8().data());
    317 #endif
    318 #if USE(JOURNALD) && !RELEASE_LOG_DISABLED
     317#elif USE(JOURNALD)
    319318        sd_journal_send("WEBKIT_SUBSYSTEM=%s", channel.subsystem, "WEBKIT_CHANNEL=%s", channel.name, "MESSAGE=%s", logMessage.utf8().data(), nullptr);
     319#else
     320        fprintf(stderr, "[%s:%s:-] %s\n", channel.subsystem, channel.name, logMessage.utf8().data());
    320321#endif
    321322
     
    338339#if RELEASE_LOG_DISABLED
    339340        WTFLogVerbose(file, line, function, &channel, "%s", logMessage.utf8().data());
    340 #endif
    341 #if USE(OS_LOG) && !RELEASE_LOG_DISABLED
     341#elif USE(OS_LOG)
    342342        os_log(channel.osLogChannel, "%{public}s", logMessage.utf8().data());
    343343        UNUSED_PARAM(file);
    344344        UNUSED_PARAM(line);
    345345        UNUSED_PARAM(function);
    346 #endif
    347 #if USE(JOURNALD) && !RELEASE_LOG_DISABLED
     346#elif USE(JOURNALD)
    348347        auto fileString = makeString("CODE_FILE=", file);
    349348        auto lineString = makeString("CODE_LINE=", line);
    350349        sd_journal_send_with_location(fileString.utf8().data(), lineString.utf8().data(), function, "WEBKIT_SUBSYSTEM=%s", channel.subsystem, "WEBKIT_CHANNEL=%s", channel.name, "MESSAGE=%s", logMessage.utf8().data(), nullptr);
     350#else
     351        fprintf(stderr, "[%s:%s:-] %s FILE=%s:%d %s\n", channel.subsystem, channel.name, logMessage.utf8().data(), file, line, function);
    351352#endif
    352353
  • trunk/Source/WebCore/ChangeLog

    r283465 r283469  
     12021-10-03  Basuke Suzuki  <basuke.suzuki@sony.com>
     2
     3        Enable release log to stderr
     4        https://bugs.webkit.org/show_bug.cgi?id=230725
     5        <rdar://problem/83740529>
     6
     7        Reviewed by Michael Catanzaro.
     8
     9        SQLiteDatabase uses hard-coded %{public} format specifiers. Replace them with defined
     10        macro.
     11
     12        No new tests because there is no behavior change.
     13
     14        * platform/sql/SQLiteDatabase.cpp:
     15        (WebCore::SQLiteDatabase::close):
     16        (WebCore::SQLiteDatabase::prepareStatementSlow):
     17        (WebCore::SQLiteDatabase::prepareStatement):
     18        (WebCore::SQLiteDatabase::prepareHeapStatementSlow):
     19        (WebCore::SQLiteDatabase::prepareHeapStatement):
     20
    1212021-10-03  Simon Fraser  <simon.fraser@apple.com>
    222
  • trunk/Source/WebCore/platform/sql/SQLiteDatabase.cpp

    r282030 r283469  
    262262
    263263        if (closeResult != SQLITE_OK)
    264             RELEASE_LOG_ERROR(SQLDatabase, "SQLiteDatabase::close: Failed to close database (%d) - %{public}s", closeResult, lastErrorMsg());
     264            RELEASE_LOG_ERROR(SQLDatabase, "SQLiteDatabase::close: Failed to close database (%d) - %" PUBLIC_LOG_STRING, closeResult, lastErrorMsg());
    265265    }
    266266
     
    718718    auto sqlStatement = constructAndPrepareStatement(*this, query.data(), query.length());
    719719    if (!sqlStatement) {
    720         RELEASE_LOG_ERROR(SQLDatabase, "SQLiteDatabase::prepareStatement: Failed to prepare statement %{public}s", query.data());
     720        RELEASE_LOG_ERROR(SQLDatabase, "SQLiteDatabase::prepareStatement: Failed to prepare statement %" PUBLIC_LOG_STRING, query.data());
    721721        return makeUnexpected(sqlStatement.error());
    722722    }
     
    728728    auto sqlStatement = constructAndPrepareStatement(*this, query.characters(), query.length());
    729729    if (!sqlStatement) {
    730         RELEASE_LOG_ERROR(SQLDatabase, "SQLiteDatabase::prepareStatement: Failed to prepare statement %{public}s", query.characters());
     730        RELEASE_LOG_ERROR(SQLDatabase, "SQLiteDatabase::prepareStatement: Failed to prepare statement %" PUBLIC_LOG_STRING, query.characters());
    731731        return makeUnexpected(sqlStatement.error());
    732732    }
     
    739739    auto sqlStatement = constructAndPrepareStatement(*this, query.data(), query.length());
    740740    if (!sqlStatement) {
    741         RELEASE_LOG_ERROR(SQLDatabase, "SQLiteDatabase::prepareHeapStatement: Failed to prepare statement %{public}s", query.data());
     741        RELEASE_LOG_ERROR(SQLDatabase, "SQLiteDatabase::prepareHeapStatement: Failed to prepare statement %" PUBLIC_LOG_STRING, query.data());
    742742        return makeUnexpected(sqlStatement.error());
    743743    }
     
    749749    auto sqlStatement = constructAndPrepareStatement(*this, query.characters(), query.length());
    750750    if (!sqlStatement) {
    751         RELEASE_LOG_ERROR(SQLDatabase, "SQLiteDatabase::prepareHeapStatement: Failed to prepare statement %{public}s", query.characters());
     751        RELEASE_LOG_ERROR(SQLDatabase, "SQLiteDatabase::prepareHeapStatement: Failed to prepare statement %" PUBLIC_LOG_STRING, query.characters());
    752752        return makeUnexpected(sqlStatement.error());
    753753    }
  • trunk/Source/cmake/WebKitFeatures.cmake

    r282628 r283469  
    196196    WEBKIT_OPTION_DEFINE(ENABLE_POINTER_LOCK "Toggle pointer lock support" PRIVATE OFF)
    197197    WEBKIT_OPTION_DEFINE(ENABLE_PUBLIC_SUFFIX_LIST "Toggle public suffix list support" PRIVATE ON)
     198    WEBKIT_OPTION_DEFINE(ENABLE_RELEASE_LOG "Toggle release log support" PRIVATE OFF)
    198199    WEBKIT_OPTION_DEFINE(ENABLE_REMOTE_INSPECTOR "Toggle remote inspector support" PRIVATE ON)
    199200    WEBKIT_OPTION_DEFINE(ENABLE_RESOURCE_USAGE "Toggle resource usage support" PRIVATE OFF)
Note: See TracChangeset for help on using the changeset viewer.