Changeset 220938 in webkit
- Timestamp:
- Aug 18, 2017 3:46:17 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r220926 r220938 1 2017-08-18 Eric Carlson <eric.carlson@apple.com> 2 3 Add WTFLogChannel level to allow runtime log filtering 4 https://bugs.webkit.org/show_bug.cgi?id=175731 5 <rdar://problem/33967234> 6 7 Reviewed by Jer Noble. 8 9 Add WTFLog*, LOG, and RELEASE_LOG variants that take a "log level" parameter so code 10 can include logging statements that are only conditionally emitted. 11 12 * wtf/Assertions.cpp: 13 * wtf/Assertions.h: 14 * wtf/MemoryPressureHandler.cpp: 15 * wtf/RefCountedLeakCounter.cpp: 16 1 17 2017-08-18 Per Arne Vollan <pvollan@apple.com> 2 18 -
trunk/Source/WTF/wtf/Assertions.cpp
r219506 r220938 411 411 } 412 412 413 void WTFSetLogChannelLevel(WTFLogChannel* channel, WTFLogLevel level) 414 { 415 channel->level = level; 416 WTFLog(channel, "Channel \"%s\" level set to %i", channel->name, level); 417 } 418 419 bool WTFWillLogWithLevel(WTFLogChannel* channel, WTFLogLevel level) 420 { 421 return channel->level >= level && channel->state != WTFLogChannelOff; 422 } 423 424 void WTFLogWithLevel(WTFLogChannel* channel, WTFLogLevel level, const char* format, ...) 425 { 426 if (channel->level < level) 427 return; 428 429 if (channel->state == WTFLogChannelOff) 430 return; 431 432 va_list args; 433 va_start(args, format); 434 435 #if COMPILER(CLANG) 436 #pragma clang diagnostic push 437 #pragma clang diagnostic ignored "-Wformat-nonliteral" 438 #endif 439 WTFLog(channel, format, args); 440 #if COMPILER(CLANG) 441 #pragma clang diagnostic pop 442 #endif 443 444 va_end(args); 445 } 446 413 447 void WTFLog(WTFLogChannel* channel, const char* format, ...) 414 448 { … … 523 557 524 558 for (size_t i = 0; i < components.size(); ++i) { 525 String component = components[i]; 559 Vector<String> componentInfo; 560 components[i].split('=', componentInfo); 561 String component = componentInfo[0].stripWhiteSpace(); 526 562 527 563 WTFLogChannelState logChannelState = WTFLogChannelOn; … … 536 572 } 537 573 538 if (WTFLogChannel* channel = WTFLogChannelByName(channels, count, component.utf8().data())) 574 WTFLogLevel logChannelLevel = WTFLogLevelError; 575 if (componentInfo.size() > 1) { 576 String level = componentInfo[1].stripWhiteSpace(); 577 if (equalLettersIgnoringASCIICase(level, "error")) 578 logChannelLevel = WTFLogLevelError; 579 else if (equalLettersIgnoringASCIICase(level, "warning")) 580 logChannelLevel = WTFLogLevelWarning; 581 else if (equalLettersIgnoringASCIICase(level, "info")) 582 logChannelLevel = WTFLogLevelInfo; 583 else if (equalLettersIgnoringASCIICase(level, "debug")) 584 logChannelLevel = WTFLogLevelDebug; 585 else 586 WTFLogAlways("Unknown logging level: %s", level.utf8().data()); 587 } 588 589 if (WTFLogChannel* channel = WTFLogChannelByName(channels, count, component.utf8().data())) { 539 590 channel->state = logChannelState; 540 else 591 channel->level = logChannelLevel; 592 } else 541 593 WTFLogAlways("Unknown logging channel: %s", component.utf8().data()); 542 594 } -
trunk/Source/WTF/wtf/Assertions.h
r219250 r220938 149 149 150 150 typedef enum { WTFLogChannelOff, WTFLogChannelOn, WTFLogChannelOnWithAccumulation } WTFLogChannelState; 151 typedef enum { WTFLogLevelError, WTFLogLevelWarning, WTFLogLevelInfo, WTFLogLevelDebug } WTFLogLevel; 151 152 152 153 typedef struct { 153 154 WTFLogChannelState state; 154 155 const char* name; 156 WTFLogLevel level; 155 157 #if !RELEASE_LOG_DISABLED 156 158 const char* subsystem; … … 172 174 #if RELEASE_LOG_DISABLED 173 175 #define DEFINE_LOG_CHANNEL(name, subsystem) \ 174 WTFLogChannel LOG_CHANNEL(name) = { WTFLogChannelOff, #name };176 WTFLogChannel LOG_CHANNEL(name) = { WTFLogChannelOff, #name, WTFLogLevelError }; 175 177 #else 176 178 #define DEFINE_LOG_CHANNEL(name, subsystem) \ 177 WTFLogChannel LOG_CHANNEL(name) = { WTFLogChannelOff, #name, subsystem, OS_LOG_DEFAULT };179 WTFLogChannel LOG_CHANNEL(name) = { WTFLogChannelOff, #name, WTFLogLevelError, subsystem, OS_LOG_DEFAULT }; 178 180 #endif 179 181 #endif … … 191 193 WTF_EXPORT_PRIVATE WTFLogChannel* WTFLogChannelByName(WTFLogChannel*[], size_t count, const char*); 192 194 WTF_EXPORT_PRIVATE void WTFInitializeLogChannelStatesFromString(WTFLogChannel*[], size_t count, const char*); 195 WTF_EXPORT_PRIVATE void WTFLogWithLevel(WTFLogChannel*, WTFLogLevel, const char* format, ...) WTF_ATTRIBUTE_PRINTF(3, 4); 196 WTF_EXPORT_PRIVATE void WTFSetLogChannelLevel(WTFLogChannel*, WTFLogLevel); 197 WTF_EXPORT_PRIVATE bool WTFWillLogWithLevel(WTFLogChannel*, WTFLogLevel); 193 198 194 199 WTF_EXPORT_PRIVATE void WTFGetBacktrace(void** stack, int* size); … … 428 433 #endif 429 434 435 /* LOG_WITH_LEVEL */ 436 437 #if LOG_DISABLED 438 #define LOG_WITH_LEVEL(channel, level, ...) ((void)0) 439 #else 440 #define LOG_WITH_LEVEL(channel, level, ...) WTFLogWithLevel(&LOG_CHANNEL(channel), level, __VA_ARGS__) 441 #endif 442 430 443 /* RELEASE_LOG */ 431 444 … … 436 449 #define RELEASE_LOG_IF( isAllowed, channel, format, ...) ((void)0) 437 450 #define RELEASE_LOG_ERROR_IF(isAllowed, channel, format, ...) do { if (isAllowed) RELEASE_LOG_ERROR(channel, format, ##__VA_ARGS__); } while (0) 451 452 #define RELEASE_LOG_WITH_LEVEL( channel, level, format, ...) ((void)0) 453 #define RELEASE_LOG_WITH_LEVEL_IF(isAllowed, channel, level, format, ...) do { if (isAllowed) RELEASE_LOG_WITH_LEVEL(channel, level, format, ##__VA_ARGS__); } while (0) 438 454 #else 439 455 #define RELEASE_LOG( channel, format, ...) os_log( LOG_CHANNEL(channel).osLogChannel, format, ##__VA_ARGS__) … … 442 458 #define RELEASE_LOG_IF( isAllowed, channel, format, ...) do { if (isAllowed) RELEASE_LOG( channel, format, ##__VA_ARGS__); } while (0) 443 459 #define RELEASE_LOG_ERROR_IF(isAllowed, channel, format, ...) do { if (isAllowed) RELEASE_LOG_ERROR(channel, format, ##__VA_ARGS__); } while (0) 460 461 #define RELEASE_LOG_WITH_LEVEL(channel, logLevel, format, ...) do { \ 462 if (LOG_CHANNEL(channel).level >= (logLevel)) \ 463 os_log(LOG_CHANNEL(channel).osLogChannel, format, ##__VA_ARGS__); \ 464 } while (0) 465 466 #define RELEASE_LOG_WITH_LEVEL_IF(isAllowed, channel, logLevel, format, ...) do { \ 467 if ((isAllowed) && LOG_CHANNEL(channel).level >= (logLevel)) \ 468 os_log(LOG_CHANNEL(channel).osLogChannel, format, ##__VA_ARGS__); \ 469 } while (0) 444 470 #endif 445 471 -
trunk/Source/WTF/wtf/MemoryPressureHandler.cpp
r219595 r220938 35 35 36 36 #if RELEASE_LOG_DISABLED 37 WTFLogChannel LogMemoryPressure = { WTFLogChannelOn, "MemoryPressure" };37 WTFLogChannel LogMemoryPressure = { WTFLogChannelOn, "MemoryPressure", WTFLogLevelError }; 38 38 #else 39 WTFLogChannel LogMemoryPressure = { WTFLogChannelOn, "MemoryPressure", LOG_CHANNEL_WEBKIT_SUBSYSTEM, OS_LOG_DEFAULT };39 WTFLogChannel LogMemoryPressure = { WTFLogChannelOn, "MemoryPressure", WTFLogLevelError, LOG_CHANNEL_WEBKIT_SUBSYSTEM, OS_LOG_DEFAULT }; 40 40 #endif 41 41 -
trunk/Source/WTF/wtf/RefCountedLeakCounter.cpp
r205275 r220938 41 41 #define LOG_CHANNEL_PREFIX Log 42 42 #if RELEASE_LOG_DISABLED 43 static WTFLogChannel LogRefCountedLeaks = { WTFLogChannelOn, "RefCountedLeaks" };43 static WTFLogChannel LogRefCountedLeaks = { WTFLogChannelOn, "RefCountedLeaks", WTFLogLevelError }; 44 44 #else 45 static WTFLogChannel LogRefCountedLeaks = { WTFLogChannelOn, "RefCountedLeaks", LOG_CHANNEL_WEBKIT_SUBSYSTEM, OS_LOG_DEFAULT };45 static WTFLogChannel LogRefCountedLeaks = { WTFLogChannelOn, "RefCountedLeaks", WTFLogLevelError, LOG_CHANNEL_WEBKIT_SUBSYSTEM, OS_LOG_DEFAULT }; 46 46 #endif 47 47 -
trunk/Tools/ChangeLog
r220925 r220938 1 2017-08-18 Eric Carlson <eric.carlson@apple.com> 2 3 Add WTFLogChannel level to allow runtime log filtering 4 https://bugs.webkit.org/show_bug.cgi?id=175731 5 <rdar://problem/33967234> 6 7 Reviewed by Jer Noble. 8 9 * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: 10 * TestWebKitAPI/Tests/WebCore/Logging.cpp: Added. 11 (TestWebKitAPI::LoggingTest::output): 12 (TestWebKitAPI::TEST_F): 13 1 14 2017-08-18 Alexey Proskuryakov <ap@apple.com> 2 15 -
trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
r220865 r220938 26 26 07492B3C1DF8B86600633DE1 /* enumerateMediaDevices.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 07492B391DF8ADA400633DE1 /* enumerateMediaDevices.html */; }; 27 27 074994421EA5034B000DA44E /* getUserMedia.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 4A410F4D19AF7BEF002EBAB5 /* getUserMedia.html */; }; 28 076E507F1F4513D6006E9F5A /* Logging.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 076E507E1F45031E006E9F5A /* Logging.cpp */; }; 28 29 0799C3491EBA2D7B003B7532 /* UserMediaDisabled.mm in Sources */ = {isa = PBXBuildFile; fileRef = 07EDEFAC1EB9400C00D43292 /* UserMediaDisabled.mm */; }; 29 30 0799C34B1EBA3301003B7532 /* disableGetUserMedia.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 0799C34A1EBA32F4003B7532 /* disableGetUserMedia.html */; }; … … 991 992 07492B3A1DF8AE2D00633DE1 /* EnumerateMediaDevices.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EnumerateMediaDevices.cpp; sourceTree = "<group>"; }; 992 993 0766DD1F1A5AD5200023E3BB /* PendingAPIRequestURL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PendingAPIRequestURL.cpp; sourceTree = "<group>"; }; 994 076E507E1F45031E006E9F5A /* Logging.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Logging.cpp; sourceTree = "<group>"; }; 993 995 0799C34A1EBA32F4003B7532 /* disableGetUserMedia.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = disableGetUserMedia.html; sourceTree = "<group>"; }; 994 996 07C046C91E42573E007201E7 /* CARingBuffer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CARingBuffer.cpp; sourceTree = "<group>"; }; … … 2031 2033 7A909A751D877475007E10F8 /* IntSize.cpp */, 2032 2034 14464012167A8305000BD218 /* LayoutUnit.cpp */, 2035 076E507E1F45031E006E9F5A /* Logging.cpp */, 2033 2036 CD225C071C45A69200140761 /* ParsedContentRange.cpp */, 2034 2037 CDCFA7A91E45122F00C2433D /* SampleMap.cpp */, … … 3255 3258 7CCE7F0C1A411AE600447C4C /* PrivateBrowsingPushStateNoHistoryCallback.cpp in Sources */, 3256 3259 4647B1261EBA3B850041D7EF /* ProcessDidTerminate.cpp in Sources */, 3260 076E507F1F4513D6006E9F5A /* Logging.cpp in Sources */, 3257 3261 7C83E0C11D0A652F00FEBCF3 /* ProvisionalURLNotChange.mm in Sources */, 3258 3262 7CCE7EC81A411A7E00447C4C /* PublicSuffix.mm in Sources */,
Note: See TracChangeset
for help on using the changeset viewer.