dispatch_async(dispatch_get_main_queue(), ^{
NSString *log = [NSString stringWithFormat:@"發(fā)送==%@==%@",[AppUtils timeWithStiring:[NSDate date] Withformat:@"yyyy-MM-dd HH:mm:ss"],urlStr];
[self logstrSet:log];
[[AppUtils getCurrentVC].view makeToast:log duration:1.5 position:CSToastPositionBottom];
});
-(void)logstrSet:(NSString*)logText{
// 獲取 Documents 目錄路徑
NSString *documentsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject];
// 創(chuàng)建日志文件路徑
NSString *logFilePath = [documentsDirectory stringByAppendingPathComponent:@"myapp.log"];
// 打開文件颖御,并追加寫入日志信息
NSFileHandle *fileHandle = [NSFileHandle fileHandleForWritingAtPath:logFilePath];
if (fileHandle == nil) {
[[NSFileManager defaultManager] createFileAtPath:logFilePath contents:nil attributes:nil];
fileHandle = [NSFileHandle fileHandleForWritingAtPath:logFilePath];
}
if (fileHandle != nil) {
// 將日志信息寫入文件
NSString *logMessage = [NSString stringWithFormat:@"\n%@========%@", [NSDate date], logText];
[fileHandle seekToEndOfFile];
[fileHandle writeData:[logMessage dataUsingEncoding:NSUTF8StringEncoding]];
[fileHandle closeFile];
}
}
自己寫個埋點(diǎn)笔咽,記錄下乾吻。