import { Component } from "@angular/core" ; import { Trace } from "@nativescript/core" ; import { Utils } from "@nativescript/core" ; @ Component ( { moduleId : module . id , templateUrl : "./trace-specific-categories-example.component.html" , styleUrls : [ "./style.css" ] } ) export class TraceSpecificCategoriesExampleComponent { constructor ( ) { Trace . disable ( ) ; Trace . setCategories ( Trace . categories . concat ( Trace . categories . Binding , Trace . categories . Layout , Trace . categories . Style , Trace . categories . ViewHierarchy , Trace . categories . VisualTreeEvents ) ) ; Trace . enable ( ) ; Trace . addCategories ( Trace . categories . Navigation ) ; Utils . setTimeout ( function ( ) { console . log ( "-----------------------------------------------------" ) ; console . log ( "New trace category has been added" ) ; console . log ( "Category: NativeLifecycle" ) ; console . log ( "-----------------------------------------------------" ) ; alert ( "NativeLifecycle trace category has been added." ) ; Trace . addCategories ( Trace . categories . NativeLifecycle ) ; } , 2000 ) ; Trace . write ( "I (heart) NativeScript!" , Trace . categories . Debug ) ; } public checkIsDebugCategorySet ( ) { if ( Trace . isCategorySet ( Trace . categories . Debug ) ) { alert ( "Debug category has been set" ) ; } else { alert ( "Debug category has not been set" ) ; } } public checkIsDebugVisualTreeEventsSet ( ) { if ( Trace . isCategorySet ( Trace . categories . VisualTreeEvents ) ) { alert ( "VisualTreeEvents category has been set" ) ; } else { alert ( "VisualTreeEvents category has not been set" ) ; } } public enableTracing ( ) { if ( Trace . isEnabled ( ) === false ) { Trace . enable ( ) ; alert ( "Trace has been enabled" ) ; } else { alert ( "Trace has been already enabled" ) ; } } public disableTracing ( ) { if ( Trace . isEnabled ( ) ) { Trace . disable ( ) ; alert ( "Trace has been disabled" ) ; } else { alert ( "Trace has been already disabled" ) ; } } }