@@ -21,7 +21,7 @@ import {
2121} from "@angular/core" ;
2222import { DOCUMENT } from "@angular/common" ;
2323
24- import { bootstrapLog , bootstrapLogError } from "./trace" ;
24+ import { bootstrapLog , bootstrapLogError , isLogEnabled } from "./trace" ;
2525import { defaultPageFactoryProvider , setRootPage , PageFactory , PAGE_FACTORY } from "./platform-providers" ;
2626import { AppHostView } from "./app-host-view" ;
2727
@@ -155,18 +155,24 @@ export class NativeScriptPlatformRef extends PlatformRef {
155155 setRootPage ( < any > tempAppHostView ) ;
156156 }
157157
158- bootstrapLog ( "NativeScriptPlatform bootstrap started." ) ;
158+ if ( isLogEnabled ( ) ) {
159+ bootstrapLog ( "NativeScriptPlatform bootstrap started." ) ;
160+ }
159161 const launchCallback = profile (
160162 "nativescript-angular/platform-common.launchCallback" ,
161163 ( args : LaunchEventData ) => {
162- bootstrapLog ( "Application launch event fired" ) ;
164+ if ( isLogEnabled ( ) ) {
165+ bootstrapLog ( "Application launch event fired" ) ;
166+ }
163167
164168 let bootstrapPromiseCompleted = false ;
165169 this . _bootstrapper ( ) . then (
166170 moduleRef => {
167171 bootstrapPromiseCompleted = true ;
168172
169- bootstrapLog ( `Angular bootstrap bootstrap done. uptime: ${ uptime ( ) } ` ) ;
173+ if ( isLogEnabled ( ) ) {
174+ bootstrapLog ( `Angular bootstrap bootstrap done. uptime: ${ uptime ( ) } ` ) ;
175+ }
170176
171177 if ( ! autoCreateFrame ) {
172178 rootContent = tempAppHostView . content ;
@@ -178,20 +184,30 @@ export class NativeScriptPlatformRef extends PlatformRef {
178184 bootstrapPromiseCompleted = true ;
179185
180186 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+ }
183193
184194 rootContent = this . createErrorUI ( errorMessage ) ;
185195 }
186196 ) ;
187197
188- bootstrapLog ( "bootstrapAction called, draining micro tasks queue. Root: " + rootContent ) ;
198+ if ( isLogEnabled ( ) ) {
199+ bootstrapLog ( "bootstrapAction called, draining micro tasks queue. Root: " + rootContent ) ;
200+ }
189201 ( < 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+ }
191205
192206 if ( ! bootstrapPromiseCompleted ) {
193207 const errorMessage = "Bootstrap promise didn't resolve" ;
194- bootstrapLogError ( errorMessage ) ;
208+ if ( isLogEnabled ( ) ) {
209+ bootstrapLogError ( errorMessage ) ;
210+ }
195211 rootContent = this . createErrorUI ( errorMessage ) ;
196212 }
197213
@@ -205,7 +221,9 @@ export class NativeScriptPlatformRef extends PlatformRef {
205221
206222 @profile
207223 public _livesync ( ) {
208- bootstrapLog ( "Angular livesync started." ) ;
224+ if ( isLogEnabled ( ) ) {
225+ bootstrapLog ( "Angular livesync started." ) ;
226+ }
209227 onBeforeLivesync . next ( lastBootstrappedModule ? lastBootstrappedModule . get ( ) : null ) ;
210228
211229 const autoCreateFrame = ! ! this . appOptions . createFrameOnBootstrap ;
@@ -226,7 +244,9 @@ export class NativeScriptPlatformRef extends PlatformRef {
226244 this . _bootstrapper ( ) . then (
227245 moduleRef => {
228246 bootstrapPromiseCompleted = true ;
229- bootstrapLog ( "Angular livesync done." ) ;
247+ if ( isLogEnabled ( ) ) {
248+ bootstrapLog ( "Angular livesync done." ) ;
249+ }
230250 onAfterLivesync . next ( { moduleRef } ) ;
231251
232252 if ( ! autoCreateFrame ) {
@@ -237,23 +257,33 @@ export class NativeScriptPlatformRef extends PlatformRef {
237257 } ,
238258 error => {
239259 bootstrapPromiseCompleted = true ;
240- bootstrapLogError ( "ERROR LIVESYNC BOOTSTRAPPING ANGULAR" ) ;
260+ if ( isLogEnabled ( ) ) {
261+ bootstrapLogError ( "ERROR LIVESYNC BOOTSTRAPPING ANGULAR" ) ;
262+ }
241263 const errorMessage = error . message + "\n\n" + error . stack ;
242- bootstrapLogError ( errorMessage ) ;
264+ if ( isLogEnabled ( ) ) {
265+ bootstrapLogError ( errorMessage ) ;
266+ }
243267
244268 rootContent = this . createErrorUI ( errorMessage ) ;
245269
246270 onAfterLivesync . next ( { error } ) ;
247271 }
248272 ) ;
249273
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+ }
251277 ( < 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+ }
253281
254282 if ( ! bootstrapPromiseCompleted ) {
255283 const result = "Livesync bootstrap promise didn't resolve" ;
256- bootstrapLogError ( result ) ;
284+ if ( isLogEnabled ( ) ) {
285+ bootstrapLogError ( result ) ;
286+ }
257287 rootContent = this . createErrorUI ( result ) ;
258288
259289 onAfterLivesync . next ( { error : new Error ( result ) } ) ;
0 commit comments