Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit c7048a0

Browse files
committed
Merge pull request #347 from Microsoft/logging
Tweaking log messages
2 parents fb736b6 + 1306c4b commit c7048a0

File tree

2 files changed

+33
-24
lines changed

2 files changed

+33
-24
lines changed

CodePush.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,15 +182,23 @@ async function tryReportStatus(resumeListener) {
182182
const previousDeploymentKey = statusReport.previousDeploymentKey || config.deploymentKey;
183183
try {
184184
if (statusReport.appVersion) {
185+
log(`Reporting binary update (${statusReport.appVersion})`);
186+
185187
const sdk = getPromisifiedSdk(requestFetchAdapter, config);
186188
await sdk.reportStatusDeploy(/* deployedPackage */ null, /* status */ null, previousLabelOrAppVersion, previousDeploymentKey);
187189
} else {
190+
const label = statusReport.package.label;
191+
if (statusReport.status === "DeploymentSucceeded") {
192+
log(`Reporting CodePush update success (${label})`);
193+
} else {
194+
log(`Reporting CodePush update rollback (${label})`);
195+
}
196+
188197
config.deploymentKey = statusReport.package.deploymentKey;
189198
const sdk = getPromisifiedSdk(requestFetchAdapter, config);
190199
await sdk.reportStatusDeploy(statusReport.package, statusReport.status, previousLabelOrAppVersion, previousDeploymentKey);
191200
}
192-
193-
log(`Reported status: ${JSON.stringify(statusReport)}`);
201+
194202
NativeCodePush.recordStatusReported(statusReport);
195203
resumeListener && AppState.removeEventListener("change", resumeListener);
196204
} catch (e) {

RestartManager.js

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,46 @@
1-
let log = require('./logging');
2-
let NativeCodePush = require("react-native").NativeModules.CodePush;
1+
const log = require("./logging");
2+
const NativeCodePush = require("react-native").NativeModules.CodePush;
33

44
const RestartManager = (() => {
55
let _allowed = true;
66
let _restartPending = false;
77

8-
function restartApp(onlyIfUpdateIsPending = false) {
9-
if (_allowed) {
10-
NativeCodePush.restartApp(onlyIfUpdateIsPending);
11-
log('restaes');
12-
} else {
13-
log("restart not allowed");
14-
_restartPending = true;
15-
return true;
16-
}
17-
}
18-
198
function allow() {
20-
log("allow restart");
9+
log("Re-allowing restarts");
2110
_allowed = true;
11+
2212
if (_restartPending) {
23-
log("executing pending restart");
13+
log("Executing pending restart");
2414
restartApp(true);
2515
}
2616
}
27-
17+
18+
function clearPendingRestart() {
19+
_restartPending = false;
20+
}
21+
2822
function disallow() {
29-
log("disallow restart");
23+
log("Disallowing restarts");
3024
_allowed = false;
3125
}
3226

33-
function clearPendingRestart() {
34-
_restartPending = false;
27+
function restartApp(onlyIfUpdateIsPending = false) {
28+
if (_allowed) {
29+
NativeCodePush.restartApp(onlyIfUpdateIsPending);
30+
log("Restarting app");
31+
} else {
32+
log("Restart request queued until restarts are re-allowed");
33+
_restartPending = true;
34+
return true;
35+
}
3536
}
3637

3738
return {
3839
allow,
40+
clearPendingRestart,
3941
disallow,
40-
restartApp,
41-
clearPendingRestart
42+
restartApp
4243
};
4344
})();
4445

45-
module.exports = RestartManager;
46+
module.exports = RestartManager;

0 commit comments

Comments
 (0)