mirror of
https://github.com/zhigang1992/react-native-code-push.git
synced 2026-06-11 08:04:23 +08:00
CPLog
This commit is contained in:
@@ -143,6 +143,8 @@ failCallback:(void (^)(NSError *err))failCallback;
|
||||
|
||||
@end
|
||||
|
||||
void CPLog(NSString *formatString, ...);
|
||||
|
||||
typedef NS_ENUM(NSInteger, CodePushInstallMode) {
|
||||
CodePushInstallModeImmediate,
|
||||
CodePushInstallModeOnNextRestart,
|
||||
|
||||
@@ -91,7 +91,7 @@ static NSString *bundleResourceName = @"main";
|
||||
NSURL *binaryBundleURL = [self binaryBundleURL];
|
||||
|
||||
if (error || !packageFile) {
|
||||
NSLog(logMessageFormat, binaryBundleURL);
|
||||
CPLog(logMessageFormat, binaryBundleURL);
|
||||
isRunningBinaryVersion = YES;
|
||||
return binaryBundleURL;
|
||||
}
|
||||
@@ -99,7 +99,7 @@ static NSString *bundleResourceName = @"main";
|
||||
NSString *binaryAppVersion = [[CodePushConfig current] appVersion];
|
||||
NSDictionary *currentPackageMetadata = [CodePushPackage getCurrentPackage:&error];
|
||||
if (error || !currentPackageMetadata) {
|
||||
NSLog(logMessageFormat, binaryBundleURL);
|
||||
CPLog(logMessageFormat, binaryBundleURL);
|
||||
isRunningBinaryVersion = YES;
|
||||
return binaryBundleURL;
|
||||
}
|
||||
@@ -110,7 +110,7 @@ static NSString *bundleResourceName = @"main";
|
||||
if ([[CodePushUpdateUtils modifiedDateStringOfFileAtURL:binaryBundleURL] isEqualToString:packageDate] && ([CodePush isUsingTestConfiguration] ||[binaryAppVersion isEqualToString:packageAppVersion])) {
|
||||
// Return package file because it is newer than the app store binary's JS bundle
|
||||
NSURL *packageUrl = [[NSURL alloc] initFileURLWithPath:packageFile];
|
||||
NSLog(logMessageFormat, packageUrl);
|
||||
CPLog(logMessageFormat, packageUrl);
|
||||
isRunningBinaryVersion = NO;
|
||||
return packageUrl;
|
||||
} else {
|
||||
@@ -123,7 +123,7 @@ static NSString *bundleResourceName = @"main";
|
||||
[CodePush clearUpdates];
|
||||
}
|
||||
|
||||
NSLog(logMessageFormat, binaryBundleURL);
|
||||
CPLog(logMessageFormat, binaryBundleURL);
|
||||
isRunningBinaryVersion = YES;
|
||||
return binaryBundleURL;
|
||||
}
|
||||
@@ -310,7 +310,7 @@ static NSString *bundleResourceName = @"main";
|
||||
if (updateIsLoading) {
|
||||
// Pending update was initialized, but notifyApplicationReady was not called.
|
||||
// Therefore, deduce that it is a broken update and rollback.
|
||||
NSLog(@"Update did not finish loading the last time, rolling back to a previous version.");
|
||||
CPLog(@"Update did not finish loading the last time, rolling back to a previous version.");
|
||||
needToReportRollback = YES;
|
||||
[self rollbackPackage];
|
||||
} else {
|
||||
@@ -582,7 +582,7 @@ RCT_EXPORT_METHOD(getConfiguration:(RCTPromiseResolveBlock)resolve
|
||||
// isRunningBinaryVersion will not get set to "YES" if running against the packager.
|
||||
NSString *binaryHash = [CodePushUpdateUtils getHashForBinaryContents:[CodePush binaryBundleURL] error:&error];
|
||||
if (error) {
|
||||
NSLog(@"Error obtaining hash for binary contents: %@", error);
|
||||
CPLog(@"Error obtaining hash for binary contents: %@", error);
|
||||
resolve(configuration);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ static NSString *const UnzippedFolderName = @"unzipped";
|
||||
error:&error];
|
||||
|
||||
if (error) {
|
||||
NSLog(@"Error downloading from URL %@", remoteBundleUrl);
|
||||
CPLog(@"Error downloading from URL %@", remoteBundleUrl);
|
||||
} else {
|
||||
NSString *currentPackageBundlePath = [self getCurrentPackageBundlePath:&error];
|
||||
[downloadedBundle writeToFile:currentPackageBundlePath
|
||||
@@ -101,7 +101,7 @@ static NSString *const UnzippedFolderName = @"unzipped";
|
||||
[[NSFileManager defaultManager] removeItemAtPath:downloadFilePath
|
||||
error:&nonFailingError];
|
||||
if (nonFailingError) {
|
||||
NSLog(@"Error deleting downloaded file: %@", nonFailingError);
|
||||
CPLog(@"Error deleting downloaded file: %@", nonFailingError);
|
||||
nonFailingError = nil;
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ static NSString *const UnzippedFolderName = @"unzipped";
|
||||
[[NSFileManager defaultManager] removeItemAtPath:unzippedFolderPath
|
||||
error:&nonFailingError];
|
||||
if (nonFailingError) {
|
||||
NSLog(@"Error deleting downloaded file: %@", nonFailingError);
|
||||
CPLog(@"Error deleting downloaded file: %@", nonFailingError);
|
||||
nonFailingError = nil;
|
||||
}
|
||||
|
||||
@@ -462,7 +462,7 @@ static NSString *const UnzippedFolderName = @"unzipped";
|
||||
[[NSFileManager defaultManager] removeItemAtPath:currentPackageFolderPath
|
||||
error:&deleteError];
|
||||
if (deleteError) {
|
||||
NSLog(@"Error deleting pending package: %@", deleteError);
|
||||
CPLog(@"Error deleting pending package: %@", deleteError);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -474,7 +474,7 @@ static NSString *const UnzippedFolderName = @"unzipped";
|
||||
[[NSFileManager defaultManager] removeItemAtPath:previousPackageFolderPath
|
||||
error:&deleteError];
|
||||
if (deleteError) {
|
||||
NSLog(@"Error deleting old package: %@", deleteError);
|
||||
CPLog(@"Error deleting old package: %@", deleteError);
|
||||
}
|
||||
}
|
||||
[info setValue:info[@"currentPackage"] forKey:@"previousPackage"];
|
||||
@@ -503,7 +503,7 @@ static NSString *const UnzippedFolderName = @"unzipped";
|
||||
[[NSFileManager defaultManager] removeItemAtPath:currentPackageFolderPath
|
||||
error:&deleteError];
|
||||
if (deleteError) {
|
||||
NSLog(@"Error deleting current package contents at %@", currentPackageFolderPath);
|
||||
CPLog(@"Error deleting current package contents at %@", currentPackageFolderPath);
|
||||
}
|
||||
|
||||
[info setValue:info[@"previousPackage"] forKey:@"currentPackage"];
|
||||
|
||||
9
ios/CodePush/CodePushUtils.m
Normal file
9
ios/CodePush/CodePushUtils.m
Normal file
@@ -0,0 +1,9 @@
|
||||
#import "CodePush.h"
|
||||
|
||||
void CPLog(NSString *formatString, ...) {
|
||||
va_list args;
|
||||
va_start(args, formatString);
|
||||
NSString *prependedFormatString = [NSString stringWithFormat:@"\n[CodePush] %@", formatString];
|
||||
NSLogv(prependedFormatString, args);
|
||||
va_end(args);
|
||||
}
|
||||
Reference in New Issue
Block a user