@@ -22,7 +22,7 @@ import {
22
22
} from "@angular/core" ;
23
23
import { DOCUMENT } from "@angular/common" ;
24
24
25
- import { bootstrapLog , bootstrapLogError } from "./trace" ;
25
+ import { bootstrapLog , bootstrapLogError , isLogEnabled } from "./trace" ;
26
26
import { defaultPageFactoryProvider , setRootPage , PageFactory , PAGE_FACTORY } from "./platform-providers" ;
27
27
import { AppHostView } from "./app-host-view" ;
28
28
@@ -156,18 +156,24 @@ export class NativeScriptPlatformRef extends PlatformRef {
156
156
setRootPage ( < any > tempAppHostView ) ;
157
157
}
158
158
159
- bootstrapLog ( "NativeScriptPlatform bootstrap started." ) ;
159
+ if ( isLogEnabled ( ) ) {
160
+ bootstrapLog ( "NativeScriptPlatform bootstrap started." ) ;
161
+ }
160
162
const launchCallback = profile (
161
163
"nativescript-angular/platform-common.launchCallback" ,
162
164
( args : LaunchEventData ) => {
163
- bootstrapLog ( "Application launch event fired" ) ;
165
+ if ( isLogEnabled ( ) ) {
166
+ bootstrapLog ( "Application launch event fired" ) ;
167
+ }
164
168
165
169
let bootstrapPromiseCompleted = false ;
166
170
this . _bootstrapper ( ) . then (
167
171
moduleRef => {
168
172
bootstrapPromiseCompleted = true ;
169
173
170
- bootstrapLog ( `Angular bootstrap bootstrap done. uptime: ${ uptime ( ) } ` ) ;
174
+ if ( isLogEnabled ( ) ) {
175
+ bootstrapLog ( `Angular bootstrap bootstrap done. uptime: ${ uptime ( ) } ` ) ;
176
+ }
171
177
172
178
if ( ! autoCreateFrame ) {
173
179
rootContent = tempAppHostView . content ;
@@ -179,20 +185,30 @@ export class NativeScriptPlatformRef extends PlatformRef {
179
185
bootstrapPromiseCompleted = true ;
180
186
181
187
const errorMessage = err . message + "\n\n" + err . stack ;
182
- bootstrapLogError ( "ERROR BOOTSTRAPPING ANGULAR" ) ;
183
- bootstrapLogError ( errorMessage ) ;
188
+ if ( isLogEnabled ( ) ) {
189
+ bootstrapLogError ( "ERROR BOOTSTRAPPING ANGULAR" ) ;
190
+ }
191
+ if ( isLogEnabled ( ) ) {
192
+ bootstrapLogError ( errorMessage ) ;
193
+ }
184
194
185
195
rootContent = this . createErrorUI ( errorMessage ) ;
186
196
}
187
197
) ;
188
198
189
- bootstrapLog ( "bootstrapAction called, draining micro tasks queue. Root: " + rootContent ) ;
199
+ if ( isLogEnabled ( ) ) {
200
+ bootstrapLog ( "bootstrapAction called, draining micro tasks queue. Root: " + rootContent ) ;
201
+ }
190
202
( < any > global ) . Zone . drainMicroTaskQueue ( ) ;
191
- bootstrapLog ( "bootstrapAction called, draining micro tasks queue finished! Root: " + rootContent ) ;
203
+ if ( isLogEnabled ( ) ) {
204
+ bootstrapLog ( "bootstrapAction called, draining micro tasks queue finished! Root: " + rootContent ) ;
205
+ }
192
206
193
207
if ( ! bootstrapPromiseCompleted ) {
194
208
const errorMessage = "Bootstrap promise didn't resolve" ;
195
- bootstrapLogError ( errorMessage ) ;
209
+ if ( isLogEnabled ( ) ) {
210
+ bootstrapLogError ( errorMessage ) ;
211
+ }
196
212
rootContent = this . createErrorUI ( errorMessage ) ;
197
213
}
198
214
@@ -206,7 +222,9 @@ export class NativeScriptPlatformRef extends PlatformRef {
206
222
207
223
@profile
208
224
public _livesync ( ) {
209
- bootstrapLog ( "Angular livesync started." ) ;
225
+ if ( isLogEnabled ( ) ) {
226
+ bootstrapLog ( "Angular livesync started." ) ;
227
+ }
210
228
onBeforeLivesync . next ( lastBootstrappedModule ? lastBootstrappedModule . get ( ) : null ) ;
211
229
212
230
const autoCreateFrame = ! ! this . appOptions . createFrameOnBootstrap ;
@@ -227,7 +245,9 @@ export class NativeScriptPlatformRef extends PlatformRef {
227
245
this . _bootstrapper ( ) . then (
228
246
moduleRef => {
229
247
bootstrapPromiseCompleted = true ;
230
- bootstrapLog ( "Angular livesync done." ) ;
248
+ if ( isLogEnabled ( ) ) {
249
+ bootstrapLog ( "Angular livesync done." ) ;
250
+ }
231
251
onAfterLivesync . next ( { moduleRef } ) ;
232
252
233
253
if ( ! autoCreateFrame ) {
@@ -238,23 +258,33 @@ export class NativeScriptPlatformRef extends PlatformRef {
238
258
} ,
239
259
error => {
240
260
bootstrapPromiseCompleted = true ;
241
- bootstrapLogError ( "ERROR LIVESYNC BOOTSTRAPPING ANGULAR" ) ;
261
+ if ( isLogEnabled ( ) ) {
262
+ bootstrapLogError ( "ERROR LIVESYNC BOOTSTRAPPING ANGULAR" ) ;
263
+ }
242
264
const errorMessage = error . message + "\n\n" + error . stack ;
243
- bootstrapLogError ( errorMessage ) ;
265
+ if ( isLogEnabled ( ) ) {
266
+ bootstrapLogError ( errorMessage ) ;
267
+ }
244
268
245
269
rootContent = this . createErrorUI ( errorMessage ) ;
246
270
247
271
onAfterLivesync . next ( { error } ) ;
248
272
}
249
273
) ;
250
274
251
- bootstrapLog ( "livesync bootstrapAction called, draining micro tasks queue. Root: " + rootContent ) ;
275
+ if ( isLogEnabled ( ) ) {
276
+ bootstrapLog ( "livesync bootstrapAction called, draining micro tasks queue. Root: " + rootContent ) ;
277
+ }
252
278
( < any > global ) . Zone . drainMicroTaskQueue ( ) ;
253
- bootstrapLog ( "livesync bootstrapAction called, draining micro tasks queue finished! Root: " + rootContent ) ;
279
+ if ( isLogEnabled ( ) ) {
280
+ bootstrapLog ( "livesync bootstrapAction called, draining micro tasks queue finished! Root: " + rootContent ) ;
281
+ }
254
282
255
283
if ( ! bootstrapPromiseCompleted ) {
256
284
const result = "Livesync bootstrap promise didn't resolve" ;
257
- bootstrapLogError ( result ) ;
285
+ if ( isLogEnabled ( ) ) {
286
+ bootstrapLogError ( result ) ;
287
+ }
258
288
rootContent = this . createErrorUI ( result ) ;
259
289
260
290
onAfterLivesync . next ( { error : new Error ( result ) } ) ;
0 commit comments