From 1a890c13ba34a65d2b820ba655db01fa72774a02 Mon Sep 17 00:00:00 2001 From: Seija K Date: Fri, 10 Feb 2023 13:12:11 -0500 Subject: [PATCH] Changed OutputToDebug to create a CFString at compile-time, rather than runtime CFStringFromCString is useful, however if we have a static C string, we can use the defined macro CFSTR to create a CFString at runtime instead. Bug: None Change-Id: I54b3f590b3ab07858409af27b817013c98556ded Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/293060 Commit-Queue: Harald Alvestrand Reviewed-by: Harald Alvestrand Auto-Submit: Seija K. Cr-Commit-Position: refs/heads/main@{#39341} --- AUTHORS | 1 + rtc_base/logging.cc | 10 +++------- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/AUTHORS b/AUTHORS index 5ec8b46310..b3cbb4db35 100644 --- a/AUTHORS +++ b/AUTHORS @@ -111,6 +111,7 @@ Saul Kravitz Sergio Garcia Murillo Shaofan Qi Shuhai Peng +Seija Silviu Caragea Stefan Gula Stephan Hartmann diff --git a/rtc_base/logging.cc b/rtc_base/logging.cc index 4bc9183d97..65d50594b6 100644 --- a/rtc_base/logging.cc +++ b/rtc_base/logging.cc @@ -363,20 +363,16 @@ void LogMessage::OutputToDebug(const LogLineRef& log_line) { // On the Mac, all stderr output goes to the Console log and causes clutter. // So in opt builds, don't log to stderr unless the user specifically sets // a preference to do so. - CFStringRef key = CFStringCreateWithCString( - kCFAllocatorDefault, "logToStdErr", kCFStringEncodingUTF8); CFStringRef domain = CFBundleGetIdentifier(CFBundleGetMainBundle()); - if (key != nullptr && domain != nullptr) { + if (domain != nullptr) { Boolean exists_and_is_valid; Boolean should_log = - CFPreferencesGetAppBooleanValue(key, domain, &exists_and_is_valid); + CFPreferencesGetAppBooleanValue(CFSTR("logToStdErr"), domain, + &exists_and_is_valid); // If the key doesn't exist or is invalid or is false, we will not log to // stderr. log_to_stderr = exists_and_is_valid && should_log; } - if (key != nullptr) { - CFRelease(key); - } #endif // defined(WEBRTC_MAC) && !defined(WEBRTC_IOS) && defined(NDEBUG) #if defined(WEBRTC_WIN)