mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-27 05:04:27 +00:00
Add private function for disabling stderr logging
This is useful for releasing sparkle-cli
This commit is contained in:
1 parent
e919c13f55
commit
34ce18c44f
2 files changed
+23
-2
No files matched your search
Vendored
+17
-2
@@ -8,15 +8,27 @@
|
||||
|
||||
#include "SULog.h"
|
||||
#include <asl.h>
|
||||
#include "SUExport.h"
|
||||
|
||||
#ifdef _APPKITDEFINES_H
|
||||
#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
|
||||
SU_EXPORT void _SULogDisableStandardErrorStream(void)
|
||||
{
|
||||
gDisableStandardErrorStream = YES;
|
||||
}
|
||||
|
||||
void SULog(NSString *format, ...)
|
||||
{
|
||||
static aslclient client;
|
||||
@@ -25,8 +37,11 @@ void SULog(NSString *format, ...)
|
||||
dispatch_once(&onceToken, ^{
|
||||
NSBundle *mainBundle = [NSBundle mainBundle];
|
||||
NSString *displayName = [[NSFileManager defaultManager] displayNameAtPath:mainBundle.bundlePath];
|
||||
#warning Can there be a better approach than always outputting to stderr?
|
||||
uint32_t options = ASL_OPT_NO_DELAY | ASL_OPT_STDERR;
|
||||
|
||||
uint32_t options = ASL_OPT_NO_DELAY;
|
||||
if (!gDisableStandardErrorStream) {
|
||||
options |= ASL_OPT_STDERR;
|
||||
}
|
||||
client = asl_open([displayName stringByAppendingString:@" [Sparkle]"].UTF8String, mainBundle.bundleIdentifier.UTF8String, options);
|
||||
queue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL);
|
||||
});
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
#import <Sparkle/Sparkle.h>
|
||||
#import "SUCommandLineUserDriver.h"
|
||||
|
||||
void _SULogDisableStandardErrorStream(void);
|
||||
|
||||
@interface SUCommandLineDriver () <SUUpdaterDelegate>
|
||||
|
||||
@property (nonatomic, readonly) SUUpdater *updater;
|
||||
@@ -52,6 +54,10 @@
|
||||
|
||||
_applicationBundlePath = applicationBundle.bundlePath;
|
||||
|
||||
#ifndef DEBUG
|
||||
_SULogDisableStandardErrorStream();
|
||||
#endif
|
||||
|
||||
id <SUUserDriver> userDriver = [[SUCommandLineUserDriver alloc] initWithApplicationBundle:applicationBundle updatePermission:updatePermission deferInstallation:deferInstallation verbose:verbose];
|
||||
_updater = [[SUUpdater alloc] initWithHostBundle:updateBundle userDriver:userDriver delegate:self];
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user