From af0a88dab3ae85bbade175d3acc4ad121f152b77 Mon Sep 17 00:00:00 2001 From: Zorg Date: Thu, 5 Jan 2017 23:09:58 -0500 Subject: [PATCH] Remove private _SULogDisableStandardErrorStream() function When using ASL, don't log to stderr if a terminal is attached. This behavior closely matches os_log() --- Sparkle/SULog.h | 2 ++ Sparkle/SULog.m | 15 ++------------- sparkle-cli/SPUCommandLineDriver.m | 6 ------ 3 files changed, 4 insertions(+), 19 deletions(-) diff --git a/Sparkle/SULog.h b/Sparkle/SULog.h index 99b84762..c09ea60a 100644 --- a/Sparkle/SULog.h +++ b/Sparkle/SULog.h @@ -19,6 +19,8 @@ typedef NS_ENUM(uint8_t, SULogLevel) { // Logging utlity function that is thread-safe // On 10.12 or later this uses os_log // Otherwise on older systems this uses ASL +// For debugging command line tools, you may have to use Console.app to view log messages +// Try to keep log messages as compact/short as possible void SULog(SULogLevel level, NSString *format, ...) NS_FORMAT_FUNCTION(2, 3); #endif diff --git a/Sparkle/SULog.m b/Sparkle/SULog.m index e10b8620..bd6100a8 100644 --- a/Sparkle/SULog.m +++ b/Sparkle/SULog.m @@ -16,22 +16,10 @@ #error This is a "core" implementation and should NOT import AppKit #endif -void _SULogDisableStandardErrorStream(void); -static BOOL gDisableStandardErrorStream; - // For converting constants to string literals using the preprocessor #define STRINGIFY(x) #x #define TO_STRING(x) STRINGIFY(x) -// Private API for disable logging to standard error stream -// We don't want to do this normally unless eg: releasing a command line utility, -// because it may be useful for error output to show up in an immediately visible terminal/panel -// Note this is only necessary for the older ASL API. This is effectively a no-op when os_log is available (10.12+) -SU_EXPORT void _SULogDisableStandardErrorStream(void) -{ - gDisableStandardErrorStream = YES; -} - void SULog(SULogLevel level, NSString *format, ...) { static aslclient client; @@ -57,7 +45,8 @@ void SULog(SULogLevel level, NSString *format, ...) #pragma clang diagnostic pop } else { uint32_t options = ASL_OPT_NO_DELAY; - if (!gDisableStandardErrorStream) { + // Act the same way os_log() does; don't log to stderr if a terminal device is attached + if (!isatty(STDERR_FILENO)) { options |= ASL_OPT_STDERR; } diff --git a/sparkle-cli/SPUCommandLineDriver.m b/sparkle-cli/SPUCommandLineDriver.m index d0991f71..e880b55a 100644 --- a/sparkle-cli/SPUCommandLineDriver.m +++ b/sparkle-cli/SPUCommandLineDriver.m @@ -10,8 +10,6 @@ #import #import "SPUCommandLineUserDriver.h" -void _SULogDisableStandardErrorStream(void); - @interface SPUCommandLineDriver () @property (nonatomic, readonly) SPUUpdater *updater; @@ -53,10 +51,6 @@ void _SULogDisableStandardErrorStream(void); _interactive = interactiveInstallation; _customFeedURL = [customFeedURL copy]; -#ifndef DEBUG - _SULogDisableStandardErrorStream(); -#endif - id userDriver = [[SPUCommandLineUserDriver alloc] initWithUpdatePermissionResponse:updatePermissionResponse deferInstallation:deferInstallation verbose:verbose]; _updater = [[SPUUpdater alloc] initWithHostBundle:updateBundle applicationBundle:applicationBundle userDriver:userDriver delegate:self]; }