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

Commit 7be3159

Browse files
committed
externalize logging function
1 parent 3570f40 commit 7be3159

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

CodePush.ios.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@ function checkForUpdate() {
117117
});
118118
}
119119

120+
/* Logs messages to console with the [CodePush] prefix */
121+
function log(message) {
122+
console.log(`[CodePush] ${message}`)
123+
}
124+
120125
/**
121126
* The sync method provides a simple, one-line experience for
122127
* incorporating the check, download and application of an update.
@@ -142,27 +147,27 @@ function sync(options = {}, syncStatusChangeCallback, downloadProgressCallback)
142147
: function(syncStatus) {
143148
switch(syncStatus) {
144149
case CodePush.SyncStatus.CHECKING_FOR_UPDATE:
145-
console.log("[CodePush] Checking for update.");
150+
log("Checking for update.");
146151
break;
147152
case CodePush.SyncStatus.DOWNLOADING_PACKAGE:
148-
console.log("[CodePush] Downloading package.");
153+
log("Downloading package.");
149154
break;
150155
case CodePush.SyncStatus.AWAITING_USER_ACTION:
151-
console.log("[CodePush] Awaiting user action.");
156+
log("Awaiting user action.");
152157
break;
153158
case CodePush.SyncStatus.INSTALLING_UPDATE:
154-
console.log("[CodePush] Installing update.");
159+
log("Installing update.");
155160
break;
156161
case CodePush.SyncStatus.IDLE:
157-
console.log("[CodePush] Sync is idle.");
162+
log("Sync is idle.");
158163
break;
159164
}
160165
};
161166

162167
downloadProgressCallback = typeof downloadProgressCallback == "function"
163168
? downloadProgressCallback
164169
: function(downloadProgress) {
165-
console.log(`[CodePush] Expecting ${downloadProgress.totalBytes} bytes, received ${downloadProgress.receivedBytes} bytes.`);
170+
log(`Expecting ${downloadProgress.totalBytes} bytes, received ${downloadProgress.receivedBytes} bytes.`);
166171
};
167172

168173
return new Promise((resolve, reject) => {

0 commit comments

Comments
 (0)