Revert some SysPrintfs in OS X to NSLogs.
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@85963 e17a0e51-4ae3-4d35-97c3-1a29b211df97
This commit is contained in:
parent
bde1f035c1
commit
04f58e9cbc
|
@ -32,11 +32,11 @@
|
|||
return nil;
|
||||
NSString *ident = [col identifier];
|
||||
if ([ident isEqualToString:@"COL_NAME"]) {
|
||||
return @(Cheats[idx].Descr);
|
||||
return [NSString stringWithCString:Cheats[idx].Descr encoding:NSUTF8StringEncoding];
|
||||
} else if ([ident isEqualToString:@"COL_ENABLE"]) {
|
||||
return @(Cheats[idx].Enabled ? NSOnState : NSOffState);
|
||||
return [NSNumber numberWithInt: Cheats[idx].Enabled ? NSOnState : NSOffState];
|
||||
}
|
||||
SysPrintf("Unknown column identifier: %s\n", [[ident description] UTF8String]);
|
||||
NSLog(@"Unknown column identifier: %@", ident);
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
@class CheatController;
|
||||
|
||||
void ShowHelpAndExit(FILE* output, int exitCode);
|
||||
void CloseEmuLog();
|
||||
|
||||
@interface PcsxrController : NSObject <NSApplicationDelegate>
|
||||
{
|
||||
|
|
|
@ -343,20 +343,9 @@ void ShowHelpAndExit(FILE* output, int exitCode)
|
|||
self.skipFiles = nil;
|
||||
}
|
||||
|
||||
- (void)applicationWillTerminate:(NSNotification *)notification
|
||||
{
|
||||
CloseEmuLog();
|
||||
}
|
||||
|
||||
static void ParseErrorStr(NSString *errStr)
|
||||
{
|
||||
NSString *logStr = [NSString stringWithFormat:@"Parse error: %@", errStr];
|
||||
|
||||
SysPrintf("%s\n", [logStr UTF8String]);
|
||||
if (!Config.PsxOut) {
|
||||
//make sure this comes out on the console.
|
||||
NSLog(@"%@", logStr);
|
||||
}
|
||||
NSLog(@"Parse error: %@", errStr);
|
||||
NSRunCriticalAlertPanel(@"Parsing error", @"%@\n\nPlease check the command line options and try again.\n\nPCSXR will now quit.", nil, nil, nil, errStr);
|
||||
ShowHelpAndExit(stderr, EXIT_FAILURE);
|
||||
}
|
||||
|
@ -470,7 +459,7 @@ otherblock();\
|
|||
void (^mcdBlock)(int mcdNumber) = ^(int mcdnumber){
|
||||
hasParsedAnArgument = YES;
|
||||
if (memcardHandled & (1 << mcdnumber)) {
|
||||
SysPrintf("Memory card %i has already been defined. The latest one passed will be used.\n", mcdnumber);
|
||||
NSLog(@"Memory card %i has already been defined. The latest one passed will be used.", mcdnumber);
|
||||
} else {
|
||||
memcardHandled |= (1 << mcdnumber);
|
||||
}
|
||||
|
@ -538,7 +527,7 @@ otherblock();\
|
|||
//As there doesn't seem to be a Cocoa/Objective-C method like this...
|
||||
NSString *unknownString = CFBridgingRelease(CFStringCreateByCombiningStrings(kCFAllocatorDefault, BRIDGE(CFArrayRef, unknownOptions), CFSTR(" ")));
|
||||
|
||||
SysPrintf("The following options weren't recognized by PCSX-R: %s. This may be due to extra arguments passed by the OS or debugger.\n", [unknownString UTF8String]);
|
||||
NSLog(@"The following options weren't recognized by PCSX-R: %@. This may be due to extra arguments passed by the OS or debugger.", unknownString);
|
||||
}
|
||||
#endif
|
||||
unknownOptions = nil;
|
||||
|
|
|
@ -147,7 +147,7 @@ static NSString *MemLabelEndLink;
|
|||
return memFlagFree;
|
||||
|
||||
//Xcode complains unless we do this...
|
||||
SysPrintf("Unknown flag %x\n", blockFlags);
|
||||
NSLog(@"Unknown flag %x", blockFlags);
|
||||
return memFlagFree;
|
||||
}
|
||||
|
||||
|
@ -169,7 +169,7 @@ static NSString *MemLabelEndLink;
|
|||
if ([englishName isEqualToString:sjisName]) {
|
||||
#if 0
|
||||
if (![englishName isEqualToString:@""])
|
||||
SysPrintf("English name and sjis name are the same: %s. Replacing the sjis string with the English string.\n", [englishName UTF8String]);
|
||||
NSLog(@"English name and sjis name are the same: %s. Replacing the sjis string with the English string.", [englishName UTF8String]);
|
||||
#endif
|
||||
self.sjisName = self.englishName;
|
||||
}
|
||||
|
|
|
@ -78,6 +78,7 @@
|
|||
{
|
||||
[plugins release];
|
||||
[defaultKey release];
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -76,7 +76,7 @@ BOOL handleHotkey(NSString* keyCode) {
|
|||
GPU_displayText((char*)[[NSString stringWithFormat:@"State Slot: %d", currentState] UTF8String]);
|
||||
break;
|
||||
default:
|
||||
SysPrintf("Invalid hotkey identifier %i.\n", [ident intValue]);
|
||||
NSLog(@"Invalid hotkey identifier %li.", [ident integerValue]);
|
||||
}
|
||||
|
||||
return YES;
|
||||
|
|
|
@ -24,36 +24,6 @@ static IOPMAssertionID powerAssertion = kIOPMNullAssertionID;
|
|||
|
||||
void PADhandleKey(int key);
|
||||
|
||||
static void LoadEmuLog()
|
||||
{
|
||||
if (emuLog == NULL) {
|
||||
#ifdef EMU_LOG
|
||||
#ifndef LOG_STDOUT
|
||||
NSFileManager *manager = [NSFileManager defaultManager];
|
||||
NSURL *supportURL = [manager URLForDirectory:NSLibraryDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:YES error:NULL];
|
||||
NSURL *logFolderURL = [supportURL URLByAppendingPathComponent:@"Logs/PCSXR"];
|
||||
if (![logFolderURL checkResourceIsReachableAndReturnError:NULL])
|
||||
[manager createDirectoryAtPath:[logFolderURL path] withIntermediateDirectories:YES attributes:nil error:NULL];
|
||||
//We use the log extension so that OS X's console app can open it by default.
|
||||
NSURL *logFileURL = [logFolderURL URLByAppendingPathComponent:@"emuLog.log"];
|
||||
|
||||
emuLog = fopen([[logFileURL path] fileSystemRepresentation],"wb");
|
||||
#else
|
||||
emuLog = stdout;
|
||||
#endif
|
||||
setvbuf(emuLog, NULL, _IONBF, 0);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void CloseEmuLog()
|
||||
{
|
||||
if (emuLog != NULL) {
|
||||
fclose(emuLog);
|
||||
emuLog = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, const char *argv[]) {
|
||||
if ( argc >= 2 && strncmp (argv[1], "-psn", 4) == 0 ) {
|
||||
char parentdir[MAXPATHLEN];
|
||||
|
@ -89,14 +59,27 @@ int main(int argc, const char *argv[]) {
|
|||
if (getenv("DISPLAY") == NULL)
|
||||
setenv("DISPLAY", ":0.0", 0); // Default to first local display
|
||||
|
||||
LoadEmuLog();
|
||||
|
||||
return NSApplicationMain(argc, argv);
|
||||
}
|
||||
|
||||
int SysInit() {
|
||||
if (!sysInited) {
|
||||
LoadEmuLog();
|
||||
#ifdef EMU_LOG
|
||||
#ifndef LOG_STDOUT
|
||||
NSFileManager *manager = [NSFileManager defaultManager];
|
||||
NSURL *supportURL = [manager URLForDirectory:NSLibraryDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:YES error:NULL];
|
||||
NSURL *logFolderURL = [supportURL URLByAppendingPathComponent:@"Logs/PCSXR"];
|
||||
if (![logFolderURL checkResourceIsReachableAndReturnError:NULL])
|
||||
[manager createDirectoryAtPath:[logFolderURL path] withIntermediateDirectories:YES attributes:nil error:NULL];
|
||||
//We use the log extension so that OS X's console app can open it by default.
|
||||
NSURL *logFileURL = [logFolderURL URLByAppendingPathComponent:@"emuLog.log"];
|
||||
|
||||
emuLog = fopen([[logFileURL path] fileSystemRepresentation],"wb");
|
||||
#else
|
||||
emuLog = stdout;
|
||||
#endif
|
||||
setvbuf(emuLog, NULL, _IONBF, 0);
|
||||
#endif
|
||||
|
||||
if (EmuInit() != 0)
|
||||
return -1;
|
||||
|
@ -112,7 +95,7 @@ int SysInit() {
|
|||
|
||||
IOReturn success = IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, CFSTR("PSX Emu Running"), &powerAssertion);
|
||||
if (success != kIOReturnSuccess) {
|
||||
SysPrintf("Unable to stop sleep, error code %d\n", success);
|
||||
NSLog(@"Unable to stop sleep, error code %d", success);
|
||||
}
|
||||
|
||||
attachHotkeys();
|
||||
|
@ -149,7 +132,7 @@ void SysPrintf(const char *fmt, ...) {
|
|||
|
||||
|
||||
dispatch_block_t printfBlock = ^{
|
||||
if (Config.PsxOut) printf ("%s", msg);
|
||||
if (Config.PsxOut) NSLog (@"%s", msg);
|
||||
#ifdef EMU_LOG
|
||||
#ifndef LOG_STDOUT
|
||||
fprintf(emuLog, "%s %s: %s",[[debugDateFormatter() stringFromDate:[NSDate date]] UTF8String],
|
||||
|
@ -167,26 +150,18 @@ void SysPrintf(const char *fmt, ...) {
|
|||
|
||||
void SysMessage(const char *fmt, ...) {
|
||||
va_list list;
|
||||
|
||||
|
||||
NSString *locFmtString = NSLocalizedString(@(fmt), nil);
|
||||
|
||||
|
||||
va_start(list, fmt);
|
||||
NSString *msg = [[NSString alloc] initWithFormat:locFmtString arguments:list];
|
||||
NSString *msg = [[NSString alloc] initWithFormat:locFmtString arguments:list];
|
||||
va_end(list);
|
||||
|
||||
NSDictionary *userInfo = [NSDictionary dictionaryWithObject:msg forKey:NSLocalizedFailureReasonErrorKey];
|
||||
|
||||
NSDictionary *userInfo = [NSDictionary dictionaryWithObject:msg forKey:NSLocalizedFailureReasonErrorKey];
|
||||
RELEASEOBJ(msg);
|
||||
|
||||
|
||||
dispatch_block_t sysBlock = ^{
|
||||
if (Config.PsxOut) printf ("%s", [msg UTF8String]);
|
||||
#ifdef EMU_LOG
|
||||
#ifndef LOG_STDOUT
|
||||
fprintf(emuLog, "%s %s: %s",[[debugDateFormatter() stringFromDate:[NSDate date]] UTF8String],
|
||||
[[[NSBundle mainBundle]objectForInfoDictionaryKey:@"CFBundleName"] UTF8String], [msg UTF8String]);
|
||||
#endif
|
||||
#endif
|
||||
[NSApp presentError:[NSError errorWithDomain:@"Unknown Domain" code:-1 userInfo:userInfo]];
|
||||
};
|
||||
|
||||
|
@ -256,7 +231,7 @@ void SysClose() {
|
|||
powerAssertion = kIOPMNullAssertionID;
|
||||
}
|
||||
|
||||
//CloseEmuLog();
|
||||
if (emuLog != NULL) fclose(emuLog);
|
||||
|
||||
sysInited = NO;
|
||||
detachHotkeys();
|
||||
|
@ -264,6 +239,7 @@ void SysClose() {
|
|||
if (((PcsxrController *)[NSApp delegate]).endAtEmuClose) {
|
||||
[NSApp stop:nil];
|
||||
}
|
||||
|
||||
//Tell the memory card manager that the memory cards changed.
|
||||
//The number three tells the mem card manager to update both cards 1 and 2.
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:memChangeNotifier object:nil userInfo:[NSDictionary dictionaryWithObject:@3 forKey:memCardChangeNumberKey]];
|
||||
|
@ -271,7 +247,6 @@ void SysClose() {
|
|||
|
||||
void OnFile_Exit() {
|
||||
SysClose();
|
||||
CloseEmuLog();
|
||||
[NSApp stop:nil];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user