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