Keep a log of uploaded crash IDs on the Mac. Review URL: http://breakpad.appspot.com/245001

git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@748 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
stuartmorgan 2010-12-17 20:41:22 +00:00
parent c45b12b422
commit 717bf0ded2
2 changed files with 31 additions and 1 deletions

View File

@ -50,10 +50,13 @@ extern "C" {
#include <CoreFoundation/CoreFoundation.h>
#include <Foundation/Foundation.h>
// Keys for configuration file
// Keys for configuration file
#define kReporterMinidumpDirectoryKey "MinidumpDir"
#define kReporterMinidumpIDKey "MinidumpID"
// Filename for recording uploaded IDs
#define kReporterLogFilename "uploads.log"
// The default subdirectory of the Library to put crash dumps in
// The subdirectory is
// ~/Library/<kDefaultLibrarySubdirectory>/<GoogleBreakpadProduct>

View File

@ -255,6 +255,9 @@ NSString *const kDefaultServerType = @"google";
// in their comments/email.
- (void)controlTextDidBeginEditing:(NSNotification *)aNotification;
// Records the uploaded crash ID to the log file.
- (void)logUploadWithID:(const char *)uploadID;
@end
@implementation Reporter
@ -992,6 +995,7 @@ doCommandBySelector:(SEL)commandSelector {
} else {
NSCharacterSet *trimSet = [NSCharacterSet whitespaceAndNewlineCharacterSet];
reportID = [[result stringByTrimmingCharactersInSet:trimSet] UTF8String];
[self logUploadWithID:reportID];
}
// rename the minidump file according to the id returned from the server
@ -1036,6 +1040,29 @@ doCommandBySelector:(SEL)commandSelector {
[upload release];
}
- (void)logUploadWithID:(const char *)uploadID {
NSString *minidumpDir =
[parameters_ objectForKey:@kReporterMinidumpDirectoryKey];
NSString *logFilePath = [NSString stringWithFormat:@"%@/%s",
minidumpDir, kReporterLogFilename];
NSString *logLine = [NSString stringWithFormat:@"%0.f,%s\n",
[[NSDate date] timeIntervalSince1970], uploadID];
NSData *logData = [logLine dataUsingEncoding:kCFStringEncodingUTF8];
NSFileManager *fileManager = [NSFileManager defaultManager];
if ([fileManager fileExistsAtPath:logFilePath]) {
NSFileHandle *logFileHandle =
[NSFileHandle fileHandleForWritingAtPath:logFilePath];
[logFileHandle seekToEndOfFile];
[logFileHandle writeData:logData];
[logFileHandle closeFile];
} else {
[fileManager createFileAtPath:logFilePath
contents:logData
attributes:nil];
}
}
//=============================================================================
- (void)dealloc {
[parameters_ release];