Skip to content

Commit bbfbc41

Browse files
committed
[Swift] WTF logging from Swift
https://bugs.webkit.org/show_bug.cgi?id=327419 rdar://168139823 Reviewed by Richard Robinson. Build idiomatic Swift APIs to wrap WTF logging. The key constraint has to be that log messages have to flow through the same gates and outputs as C++ WTF logging, which is quite nuanced on different WebKit platforms. WebKit.LogChannel.BackForward().debugLog.log("...") // LOG WebKit.LogChannel.Loading().releaseLog.log("...") // RELEASE_LOG WebKit.LogChannel.Loading().releaseLog.error("...") // RELEASE_LOG_ERROR etc. On Cocoa both are an os.Logger for the channel's os_log_t, so call sites get the compiler's os_log handling: static format strings, per-argument privacy and lazily evaluated arguments. os.Logger cannot be wrapped without losing that, so the API returns it directly. debugLog discards everything when the channel is off. Where LOG is compiled out, it is a no-op NullLogger instead, so neither the messages nor the calls remain in the binary, which os.Logger(.disabled) cannot achieve. Elsewhere, a PortableLogger stands in for os.Logger. Its debug logs go through WTFLog(), and its release logs through WTF_RELEASE_LOG_SEND, now the single implementation of each non-os_log RELEASE_LOG backend, shared by C++ and Swift. This also fixes the previous Swift shims, which passed every RELEASE_LOG message as a single "%s", so it was <private> in production logs. Limitations: 1. On Cocoa, Swift debug logs go only to os_log. They do not reach stderr, where C++ LOG output on the same channel still goes, or the log accumulator that tests use to capture a channel's output. 2. Swift has no LOG_DISABLED compile condition, so it uses ASSERT_ENABLED in its place. A static_assert enforces LOG_DISABLED == !ASSERT_ENABLED, so no build can configure LOG independently of assertions any more. Nothing does so today. * Source/WTF/wtf/Assertions.h: Make WTFLogChannel an immortal Swift reference type, and factor out WTF_RELEASE_LOG_SEND. journald now passes CODE_FILE, CODE_LINE and CODE_FUNC as sd_journal_send() fields, so the location need not be a literal. * Source/WTF/wtf/Logging.cpp: (WTF::logPreformatted): (WTF::releaseLogPriority): (WTF::releaseLogPreformatted): * Source/WTF/wtf/Logging.h: (WTF::osLog): * Source/WebKit/CMakeLists.txt: * Source/WebKit/Platform/Logging.h: * Source/WebKit/Platform/Logging.swift: Added. * Source/WebKit/UIProcess/WebBackForwardList.cpp: (doLog): Deleted. (doLoadingReleaseLog): Deleted. * Source/WebKit/UIProcess/WebBackForwardList.swift: (WebBackForwardList.init(page:)): (WebBackForwardList.deinit): (WebBackForwardList.pageClosed): (WebBackForwardList.addItem(newItem:)): (WebBackForwardList.goToItem(item:)): (WebBackForwardList.removeAllItems): (WebBackForwardList.clear): (WebBackForwardList.restoreFromState(backForwardListState:)): (WebBackForwardList.itemStartingAtIndexSkippingItemsAddedByJSWithoutUserGesture(direction:startingIndex:)): (backForwardLog(_:)): Deleted. (loadingReleaseLog(_:)): Deleted. * Source/WebKit/UIProcess/WebBackForwardListSwiftUtilities.h: * Source/WebKit/WebKit.xcodeproj/project.pbxproj: Canonical link: https://commits.webkit.org/324710@main
1 parent cc002ef commit bbfbc41

10 files changed

Lines changed: 398 additions & 99 deletions

File tree

‎Source/WTF/wtf/Assertions.h‎

Lines changed: 51 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
#include <stdlib.h>
4848
#include <wtf/ExportMacros.h>
4949
#include <wtf/StdIntExtras.h>
50+
#include <wtf/SwiftBridging.h>
5051

5152
#if OS(ANDROID)
5253
#include <android/log.h>
@@ -171,7 +172,8 @@ typedef uint8_t WTFLogChannelState;
171172
typedef uint8_t WTFLogLevel;
172173
#endif
173174

174-
typedef struct {
175+
// Channels are global variables that are never destroyed.
176+
typedef struct SWIFT_IMMORTAL_REFERENCE {
175177
WTFLogChannelState state;
176178
const char* name;
177179
WTFLogLevel level;
@@ -850,28 +852,22 @@ WTF_ALLOW_UNSAFE_BUFFER_USAGE_END \
850852

851853
#elif OS(ANDROID)
852854

853-
#define LOG_ANDROID_SEND(channel, priority, fmt, ...) do { \
854-
auto& logChannel = LOG_CHANNEL(channel); \
855+
// WTF_RELEASE_LOG_SEND is the only implementation of RELEASE_LOG for each non-os_log platform.
856+
// WTF::releaseLogPreformatted() also uses it, so that Swift shares the backend.
857+
#define WTF_RELEASE_LOG_PRIORITY_DEFAULT ANDROID_LOG_VERBOSE
858+
#define WTF_RELEASE_LOG_PRIORITY_INFO ANDROID_LOG_INFO
859+
#define WTF_RELEASE_LOG_PRIORITY_DEBUG ANDROID_LOG_DEBUG
860+
#define WTF_RELEASE_LOG_PRIORITY_ERROR ANDROID_LOG_ERROR
861+
#define WTF_RELEASE_LOG_PRIORITY_FAULT ANDROID_LOG_FATAL
862+
#define WTF_RELEASE_LOG_WITH_LEVEL_PRIORITY(logLevel) WTF_RELEASE_LOG_PRIORITY_DEFAULT
863+
864+
#define WTF_RELEASE_LOG_SEND(channel, priority, file, line, function, fmt, ...) do { \
865+
auto& logChannel = (channel); \
855866
if (logChannel.state != WTFLogChannelState::Off) \
856-
__android_log_print(ANDROID_LOG_ ## priority, LOG_CHANNEL_WEBKIT_SUBSYSTEM, "[%s] " fmt, logChannel.name WTF_LOG_PRINTF_ARGS(__VA_ARGS__)); \
867+
__android_log_print(priority, LOG_CHANNEL_WEBKIT_SUBSYSTEM, "[%s] " fmt, logChannel.name WTF_LOG_PRINTF_ARGS(__VA_ARGS__)); \
857868
} while (0)
858869

859-
#define RELEASE_LOG(channel, ...) LOG_ANDROID_SEND(channel, VERBOSE, __VA_ARGS__)
860-
#define RELEASE_LOG_ERROR(channel, ...) LOG_ANDROID_SEND(channel, ERROR, __VA_ARGS__)
861-
#define RELEASE_LOG_FAULT(channel, ...) LOG_ANDROID_SEND(channel, FATAL, __VA_ARGS__)
862870
#define RELEASE_LOG_FAULT_WITH_PAYLOAD(channel, format, ...) RELEASE_LOG_FAULT(channel, format __VA_OPT__(, __VA_ARGS__))
863-
#define RELEASE_LOG_INFO(channel, ...) LOG_ANDROID_SEND(channel, INFO, __VA_ARGS__)
864-
#define RELEASE_LOG_DEBUG(channel, ...) LOG_ANDROID_SEND(channel, DEBUG, __VA_ARGS__)
865-
866-
#define RELEASE_LOG_WITH_LEVEL(channel, logLevel, ...) do { \
867-
if (LOG_CHANNEL(channel).level >= (logLevel)) \
868-
LOG_ANDROID_SEND(channel, VERBOSE, __VA_ARGS__); \
869-
} while (0)
870-
871-
#define RELEASE_LOG_WITH_LEVEL_IF(isAllowed, channel, logLevel, ...) do { \
872-
if ((isAllowed) && LOG_CHANNEL(channel).level >= (logLevel)) \
873-
LOG_ANDROID_SEND(channel, VERBOSE, __VA_ARGS__); \
874-
} while (0)
875871

876872
#elif ENABLE(JOURNALD_LOG)
877873

@@ -903,66 +899,73 @@ inline const char* wtfLogPriorityName(int priority)
903899

904900
#define JOURNAL_FALLBACK_LOGF(logChannel, priority, file, line, function, fmt, ...) do { \
905901
IGNORE_WARNINGS_BEGIN("unsafe-buffer-usage-in-libc-call") \
906-
fprintf(stderr, "[" LOG_CHANNEL_WEBKIT_SUBSYSTEM ":%s:%s] " fmt " [" file ":" line " %s]\n", logChannel.name, wtfLogPriorityName(priority) WTF_LOG_PRINTF_ARGS(__VA_ARGS__), function); \
902+
fprintf(stderr, "[" LOG_CHANNEL_WEBKIT_SUBSYSTEM ":%s:%s] " fmt " [%s:%u %s]\n", logChannel.name, wtfLogPriorityName(priority) WTF_LOG_PRINTF_ARGS(__VA_ARGS__), file, static_cast<unsigned>(line), function); /* NOLINT(safercpp/printf): SAFE_FPRINTF rejects the const char* arguments that the logging macros accept. */ \
907903
IGNORE_WARNINGS_END \
908904
} while (0)
909905

910-
#define SD_JOURNAL_SEND(channel, priority, file, line, function, fmt, ...) do { \
906+
#define WTF_RELEASE_LOG_PRIORITY_DEFAULT LOG_NOTICE
907+
#define WTF_RELEASE_LOG_PRIORITY_INFO LOG_INFO
908+
#define WTF_RELEASE_LOG_PRIORITY_DEBUG LOG_DEBUG
909+
#define WTF_RELEASE_LOG_PRIORITY_ERROR LOG_ERR
910+
#define WTF_RELEASE_LOG_PRIORITY_FAULT LOG_CRIT
911+
#define WTF_RELEASE_LOG_WITH_LEVEL_PRIORITY(logLevel) WTF_RELEASE_LOG_PRIORITY_INFO
912+
913+
// The CODE_* fields are what sd_journal_send_with_location() adds, but this form also accepts a location that is not a literal.
914+
#define WTF_RELEASE_LOG_SEND(channel, priority, file, line, function, fmt, ...) do { \
911915
IGNORE_WARNINGS_BEGIN("unsafe-buffer-usage-in-format-attr-call") \
912916
wtfCompileTimeCheckPrintfSpecifier(fmt WTF_LOG_PRINTF_ARGS(__VA_ARGS__)); \
913-
auto& logChannel = LOG_CHANNEL(channel); \
917+
auto& logChannel = (channel); \
914918
if (logChannel.state != WTFLogChannelState::Off) { \
915919
if (WTFShouldLogToJournal()) \
916-
sd_journal_send_with_location("CODE_FILE=" file, "CODE_LINE=" line, function, "WEBKIT_SUBSYSTEM=" LOG_CHANNEL_WEBKIT_SUBSYSTEM, "WEBKIT_CHANNEL=%s", logChannel.name, "PRIORITY=%u", static_cast<unsigned>(priority), "MESSAGE=" fmt WTF_LOG_PRINTF_ARGS(__VA_ARGS__), nullptr); \
920+
sd_journal_send("CODE_FILE=%s", file, "CODE_LINE=%u", static_cast<unsigned>(line), "CODE_FUNC=%s", function, "WEBKIT_SUBSYSTEM=" LOG_CHANNEL_WEBKIT_SUBSYSTEM, "WEBKIT_CHANNEL=%s", logChannel.name, "PRIORITY=%u", static_cast<unsigned>(priority), "MESSAGE=" fmt WTF_LOG_PRINTF_ARGS(__VA_ARGS__), nullptr); \
917921
else \
918922
JOURNAL_FALLBACK_LOGF(logChannel, priority, file, line, function, fmt __VA_OPT__(, __VA_ARGS__)); \
919923
} \
920924
IGNORE_WARNINGS_END \
921925
} while (0)
922926

923-
#define RELEASE_LOG(channel, ...) SD_JOURNAL_SEND(channel, LOG_NOTICE, __FILE__, _STRINGIFY(__LINE__), __func__, __VA_ARGS__)
924-
#define RELEASE_LOG_ERROR(channel, ...) SD_JOURNAL_SEND(channel, LOG_ERR, __FILE__, _STRINGIFY(__LINE__), __func__, __VA_ARGS__)
925-
#define RELEASE_LOG_FAULT(channel, ...) SD_JOURNAL_SEND(channel, LOG_CRIT, __FILE__, _STRINGIFY(__LINE__), __func__, __VA_ARGS__)
926927
#define RELEASE_LOG_FAULT_WITH_PAYLOAD(channel, format, ...) RELEASE_LOG_FAULT(channel, format __VA_OPT__(, SAFE_PRINTF_TYPE(__VA_ARGS__)))
927-
#define RELEASE_LOG_INFO(channel, ...) SD_JOURNAL_SEND(channel, LOG_INFO, __FILE__, _STRINGIFY(__LINE__), __func__, __VA_ARGS__)
928-
#define RELEASE_LOG_DEBUG(channel, ...) SD_JOURNAL_SEND(channel, LOG_DEBUG, __FILE__, _STRINGIFY(__LINE__), __func__, __VA_ARGS__)
929-
930-
#define RELEASE_LOG_WITH_LEVEL(channel, logLevel, ...) do { \
931-
if (LOG_CHANNEL(channel).level >= (logLevel)) \
932-
SD_JOURNAL_SEND(channel, LOG_INFO, __FILE__, _STRINGIFY(__LINE__), __func__, __VA_ARGS__); \
933-
} while (0)
934-
935-
#define RELEASE_LOG_WITH_LEVEL_IF(isAllowed, channel, logLevel, ...) do { \
936-
if ((isAllowed) && LOG_CHANNEL(channel).level >= (logLevel)) \
937-
SD_JOURNAL_SEND(channel, LOG_INFO, __FILE__, _STRINGIFY(__LINE__), __func__, __VA_ARGS__); \
938-
} while (0)
939928

940929
#else
941930

942-
#define LOGF(channel, priority, fmt, ...) do { \
943-
auto& logChannel = LOG_CHANNEL(channel); \
931+
#define WTF_RELEASE_LOG_PRIORITY_DEFAULT 4
932+
#define WTF_RELEASE_LOG_PRIORITY_INFO 3
933+
#define WTF_RELEASE_LOG_PRIORITY_DEBUG 4
934+
#define WTF_RELEASE_LOG_PRIORITY_ERROR 1
935+
#define WTF_RELEASE_LOG_PRIORITY_FAULT 2
936+
#define WTF_RELEASE_LOG_WITH_LEVEL_PRIORITY(logLevel) (logLevel)
937+
938+
#define WTF_RELEASE_LOG_SEND(channel, priority, file, line, function, fmt, ...) do { \
939+
auto& logChannel = (channel); \
944940
if (logChannel.state != WTFLogChannelState::Off) { \
945941
IGNORE_WARNINGS_BEGIN("unsafe-buffer-usage-in-libc-call") \
946-
fprintf(stderr, "[" LOG_CHANNEL_WEBKIT_SUBSYSTEM ":%s:%u] " fmt "\n", logChannel.name, static_cast<unsigned>(priority) WTF_LOG_PRINTF_ARGS(__VA_ARGS__)); \
942+
fprintf(stderr, "[" LOG_CHANNEL_WEBKIT_SUBSYSTEM ":%s:%u] " fmt "\n", logChannel.name, static_cast<unsigned>(priority) WTF_LOG_PRINTF_ARGS(__VA_ARGS__)); /* NOLINT(safercpp/printf): SAFE_FPRINTF rejects the const char* arguments that the logging macros accept. */ \
947943
IGNORE_WARNINGS_END \
948944
} \
949945
} while (0)
950946

951-
#define RELEASE_LOG(channel, ...) LOGF(channel, 4, __VA_ARGS__)
952-
#define RELEASE_LOG_ERROR(channel, ...) LOGF(channel, 1, __VA_ARGS__)
953-
#define RELEASE_LOG_FAULT(channel, ...) LOGF(channel, 2, __VA_ARGS__)
954947
#define RELEASE_LOG_FAULT_WITH_PAYLOAD(channel, format, ...) RELEASE_LOG_FAULT(channel, format __VA_OPT__(, __VA_ARGS__))
955-
#define RELEASE_LOG_INFO(channel, ...) LOGF(channel, 3, __VA_ARGS__)
956-
#define RELEASE_LOG_DEBUG(channel, ...) LOGF(channel, 4, __VA_ARGS__)
948+
949+
#endif
950+
951+
#if !RELEASE_LOG_DISABLED && !USE(OS_LOG)
952+
953+
#define WTF_RELEASE_LOG_AT(channel, priority, ...) WTF_RELEASE_LOG_SEND(LOG_CHANNEL(channel), priority, __FILE__, __LINE__, __func__, __VA_ARGS__)
954+
955+
#define RELEASE_LOG(channel, ...) WTF_RELEASE_LOG_AT(channel, WTF_RELEASE_LOG_PRIORITY_DEFAULT, __VA_ARGS__)
956+
#define RELEASE_LOG_ERROR(channel, ...) WTF_RELEASE_LOG_AT(channel, WTF_RELEASE_LOG_PRIORITY_ERROR, __VA_ARGS__)
957+
#define RELEASE_LOG_FAULT(channel, ...) WTF_RELEASE_LOG_AT(channel, WTF_RELEASE_LOG_PRIORITY_FAULT, __VA_ARGS__)
958+
#define RELEASE_LOG_INFO(channel, ...) WTF_RELEASE_LOG_AT(channel, WTF_RELEASE_LOG_PRIORITY_INFO, __VA_ARGS__)
959+
#define RELEASE_LOG_DEBUG(channel, ...) WTF_RELEASE_LOG_AT(channel, WTF_RELEASE_LOG_PRIORITY_DEBUG, __VA_ARGS__)
957960

958961
#define RELEASE_LOG_WITH_LEVEL(channel, logLevel, ...) do { \
959962
if (LOG_CHANNEL(channel).level >= (logLevel)) \
960-
LOGF(channel, logLevel, __VA_ARGS__); \
963+
WTF_RELEASE_LOG_AT(channel, WTF_RELEASE_LOG_WITH_LEVEL_PRIORITY(logLevel), __VA_ARGS__); \
961964
} while (0)
962965

963966
#define RELEASE_LOG_WITH_LEVEL_IF(isAllowed, channel, logLevel, ...) do { \
964967
if ((isAllowed) && LOG_CHANNEL(channel).level >= (logLevel)) \
965-
LOGF(channel, logLevel, __VA_ARGS__); \
968+
WTF_RELEASE_LOG_AT(channel, WTF_RELEASE_LOG_WITH_LEVEL_PRIORITY(logLevel), __VA_ARGS__); \
966969
} while (0)
967970

968971
#endif

‎Source/WTF/wtf/Logging.cpp‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
#include "config.h"
2727
#include <wtf/Logging.h>
2828

29+
#include <wtf/StdLibExtras.h>
30+
#include <wtf/text/CString.h>
31+
#include <wtf/text/WTFString.h>
32+
2933
namespace WTF {
3034

3135
#if !LOG_DISABLED || !RELEASE_LOG_DISABLED
@@ -38,6 +42,43 @@ DEFINE_LOG_CHANNEL(MemoryPressure);
3842
DEFINE_LOG_CHANNEL(SuspendableWorkQueue);
3943
DEFINE_LOG_CHANNEL(NativePromise);
4044

45+
void logPreformatted([[maybe_unused]] WTFLogChannel& channel, [[maybe_unused]] const String& message)
46+
{
47+
#if !LOG_DISABLED
48+
if (channel.state != WTFLogChannelState::Off)
49+
SAFE_WTFLOG(&channel, "%s", message.utf8());
50+
#endif
51+
}
52+
53+
#if !USE(OS_LOG) && !RELEASE_LOG_DISABLED
54+
55+
static int releaseLogPriority(ReleaseLogType type)
56+
{
57+
switch (type) {
58+
case ReleaseLogType::Default:
59+
return WTF_RELEASE_LOG_PRIORITY_DEFAULT;
60+
case ReleaseLogType::Info:
61+
return WTF_RELEASE_LOG_PRIORITY_INFO;
62+
case ReleaseLogType::Debug:
63+
return WTF_RELEASE_LOG_PRIORITY_DEBUG;
64+
case ReleaseLogType::Error:
65+
return WTF_RELEASE_LOG_PRIORITY_ERROR;
66+
case ReleaseLogType::Fault:
67+
return WTF_RELEASE_LOG_PRIORITY_FAULT;
68+
}
69+
RELEASE_ASSERT_NOT_REACHED();
70+
}
71+
72+
void releaseLogPreformatted(WTFLogChannel& channel, ReleaseLogType type, const String& file, unsigned line, const String& function, const String& message)
73+
{
74+
auto fileUTF8 = file.utf8();
75+
auto functionUTF8 = function.utf8();
76+
auto messageUTF8 = message.utf8();
77+
WTF_RELEASE_LOG_SEND(channel, releaseLogPriority(type), safePrintfType(fileUTF8), line, safePrintfType(functionUTF8), "%s", messageUTF8);
78+
}
79+
80+
#endif // !USE(OS_LOG) && !RELEASE_LOG_DISABLED
81+
4182
#endif // !LOG_DISABLED || !RELEASE_LOG_DISABLED
4283

4384
} // namespace WTF

‎Source/WTF/wtf/Logging.h‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030

3131
namespace WTF {
3232

33+
// Swift cannot see LOG_DISABLED, so it decides whether LOG is compiled in from ASSERT_ENABLED.
34+
static_assert(!LOG_DISABLED == !!ASSERT_ENABLED, "Swift's debugLog assumes that LOG is compiled in exactly when ASSERT_ENABLED is");
35+
3336
#if !LOG_DISABLED || !RELEASE_LOG_DISABLED
3437

3538
#ifndef LOG_CHANNEL_PREFIX
@@ -51,6 +54,29 @@ namespace WTF {
5154

5255
WTF_LOG_CHANNELS(DECLARE_LOG_CHANNEL)
5356

57+
// Lets Swift name a channel, e.g. WTF.LogChannel.Process(), since it cannot use LOG_CHANNEL.
58+
struct LogChannel {
59+
#define DEFINE_LOG_CHANNEL_ACCESSOR(name) static WTFLogChannel& name() { return LOG_CHANNEL(name); }
60+
WTF_LOG_CHANNELS(DEFINE_LOG_CHANNEL_ACCESSOR)
61+
#undef DEFINE_LOG_CHANNEL_ACCESSOR
62+
};
63+
64+
// Entry points for Swift, which cannot use the LOG and RELEASE_LOG macros.
65+
// See the WTFLogChannel extension in Swift for the idiomatic API.
66+
67+
// Behaves like LOG_WITH_STREAM(channel, stream << message).
68+
WTF_EXPORT_PRIVATE void logPreformatted(WTFLogChannel&, const String& message);
69+
70+
#if USE(OS_LOG) && !RELEASE_LOG_DISABLED
71+
// RELEASE_LOG is os_log on this handle, so Swift can use os.Logger(osLog(channel)) directly.
72+
inline os_log_t osLog(const WTFLogChannel& channel) { return channel.osLogChannel; }
73+
#elif !RELEASE_LOG_DISABLED
74+
enum class ReleaseLogType : uint8_t { Default, Info, Debug, Error, Fault };
75+
76+
// RELEASE_LOG(channel, "%s", message) through the same WTF_RELEASE_LOG_SEND backend, with the location of the Swift caller.
77+
WTF_EXPORT_PRIVATE void releaseLogPreformatted(WTFLogChannel&, ReleaseLogType, const String& file, unsigned line, const String& function, const String& message);
78+
#endif
79+
5480
#endif // !LOG_DISABLED || !RELEASE_LOG_DISABLED
5581

5682
} // namespace WTF

‎Source/WebKit/CMakeLists.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1490,6 +1490,7 @@ if (ENABLE_BACK_FORWARD_LIST_SWIFT)
14901490
PROPERTIES GENERATED TRUE)
14911491
list(APPEND WebKit_SOURCES
14921492
${WebKit_DERIVED_SOURCES_DIR}/WebBackForwardListMessageReceiver.swift
1493+
${WEBKIT_DIR}/Platform/Logging.swift
14931494
${WEBKIT_DIR}/Shared/API/APIArray.swift
14941495
${WEBKIT_DIR}/UIProcess/StdlibExtras.swift
14951496
${WEBKIT_DIR}/UIProcess/WebBackForwardList.swift

‎Source/WebKit/Platform/Logging.h‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,17 @@ WEBKIT2_LOG_CHANNELS(DECLARE_LOG_CHANNEL)
195195

196196
#ifdef __cplusplus
197197
}
198+
199+
namespace WebKit {
200+
201+
// Lets Swift name a channel, e.g. WebKit.LogChannel.BackForward(), since it cannot use LOG_CHANNEL.
202+
struct LogChannel {
203+
#define DEFINE_LOG_CHANNEL_ACCESSOR(name) static WTFLogChannel& name() { return LOG_CHANNEL(name); }
204+
WEBKIT2_LOG_CHANNELS(DEFINE_LOG_CHANNEL_ACCESSOR)
205+
#undef DEFINE_LOG_CHANNEL_ACCESSOR
206+
};
207+
208+
} // namespace WebKit
198209
#endif
199210

200211
#endif // !LOG_DISABLED || !RELEASE_LOG_DISABLED

0 commit comments

Comments
 (0)