Created
August 17, 2015 03:57
-
-
Save jbristowe/2bb817a3d2adb4f9b58d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var listener = new Listener("NativeScript Rocks!!11!"); | |
trace.addEventListener(listener); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trace.clearWriters(); | |
trace.addWriter(new TimestampConsoleWriter()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Listener = (function () { | |
function Listener(filter) { | |
this.filter = filter; | |
} | |
Listener.prototype.on = function (object, name, data) { | |
// validate parameters and do something for trace.notifyEvent() | |
}; | |
return Listener; | |
})(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var TimestampConsoleWriter = (function () { | |
function TimestampConsoleWriter() { } | |
TimestampConsoleWriter.prototype.write = function (message, category, type) { | |
if (!console) return; | |
var msgType = types.isUndefined(type) ? trace.messageType.log : type; | |
var traceMessage = new Date().toISOString() + " " + category + ": " + message; | |
switch (msgType) { | |
case trace.messageType.log: | |
console.log(traceMessage); | |
break; | |
case trace.messageType.info: | |
console.info(traceMessage); | |
break; | |
case trace.messageType.warn: | |
console.warn(traceMessage); | |
break; | |
case trace.messageType.error: | |
console.error(traceMessage); | |
break; | |
} | |
}; | |
return TimestampConsoleWriter; | |
})(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trace.disable(); // tracing disabled -- party pooper! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var trace = require("trace"); | |
trace.enable(); // tracing enabled -- let's party! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log("Hello, NativeScript!"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// add the binding category to the existing list of trace messages | |
trace.addCategories(trace.categories.Binding); | |
// filter out all trace messages except those that are animation and debug categories | |
trace.setCategories(trace.categories.concat(trace.categories.Animation, trace.categories.Debug)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var data = { /* ... */ }; | |
trace.notifyEvent(this, "NativeScript Rocks!!11!", data); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trace.write("I (heart) NativeScript!", trace.categories.Debug); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trace.setCategories("Questions"); | |
trace.write("NativeScript: Great technology or the greatest technology?", "Questions"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment