add trace support (#38)

* add basic support for sending console logs to OutputWindow

* add trace config setting

* standardise logs
This commit is contained in:
Dave Holoway
2018-11-11 17:57:32 +00:00
committed by GitHub
parent 8cc31476b3
commit de8abc62bc
5 changed files with 35 additions and 10 deletions

View File

@@ -1,13 +1,18 @@
const crypto = require('crypto');
var nofn = function () { };
var D = exports.D = console.log.bind(console);
var E = exports.E = console.error.bind(console);
var W = exports.W = console.warn.bind(console);
const messagePrintCallbacks = new Set();
var D = exports.D = (...args) => (console.log(...args), messagePrintCallbacks.forEach(cb => cb(...args)))
var E = exports.E = (...args) => (console.error(...args), messagePrintCallbacks.forEach(cb => cb(...args)))
var W = exports.W = (...args) => (console.warn(...args), messagePrintCallbacks.forEach(cb => cb(...args)))
var DD = nofn, cl = D, printf = D;
var print_jdwp_data = nofn;// _print_jdwp_data;
var print_packet = nofn;//_print_packet;
exports.onMessagePrint = function(cb) {
messagePrintCallbacks.add(cb);
}
Array.first = function (arr, fn, defaultvalue) {
var idx = Array.indexOfFirst(arr, fn);
return idx < 0 ? defaultvalue : arr[idx];