Skip to content
Simple NativeScript Tracing for Classes
JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
.npmignore
LICENSE
README.md
package.json
tracing.js

README.md

npm npm npm

NativeScript tracing

A NativeScript module providing basic tracing actions for Android and iOS.

License

This is released under the MIT License, meaning you are free to include this in any type of program -- However for entities that need a support and/or a commercial license please contact me at http://nativescript.tools.

I also do contract work; so if you have a module you want built for NativeScript (or any other software projects) feel free to contact me nathan@master-technology.com.

Donate Patreon

Installation

Run tns plugin add nativescript-tracing from inside your main project's directory:

Usage

To use the tracing module you must first require() it from your project's node_modules directory:

var Tracing = require( "nativescript-tracing" );

Methods

Tracing(class, options);

Parameters
  • class: your class you want to add tracing too
  • (optional) options object:
    ** disableAddedFunction - This will disable adding the option "tracing" function that will disable/enable the console logging. ** ignore - array of functions that you don't want to add tracing too.
  • RETURNS: Nothing
// my-page.js
var Sqlite = require( "/path/to/node_modules/nativescript-sqlite/sqlite" );
var Tracing = require( "/path/to/node_modules/nativescript-tracing/tracing");

Tracing(Sqlite, {ignore: ["close"], disableAddedFunction: true});


var db_promise = new Sqlite("MyTable", function(err, db) {
    if (err) { 
      console.error("We failed to open database", err);
    } else {
      // This should ALWAYS be true, db object is open in the "Callback" if no errors occurred
      console.log("Are we open yet (Inside Callback)? ", db.isOpen() ? "Yes" : "No"); // Yes
    }
});

db_promise.then(function(db) {
    // This should ALWAYS be true, db object is open in the "then"
      console.log("Are we open yet (Inside Promise)? ", db.isOpen() ? "Yes" : "No"); // Yes
      db.close();
   }, function(err) {
     console.error("We failed to open database", err);
   });

This should output something like:

  • Starting Sqlite: MyTable, (callback)
  • Starting isOpen
  • Ending isOpen Are we open (callback)
  • Starting isOpen
  • Ending isOpen Are we open (Promise)
  • ---- PLEASE note if we hadn't put the "close" in the ignore array it would have shown up here
  • Ending Sqlite: MyTable
You can’t perform that action at this time.