aboutsummaryrefslogtreecommitdiff
path: root/src/Utils.ts
diff options
context:
space:
mode:
authorSam Wilkins <samwilkins333@gmail.com>2020-02-02 12:47:57 -0500
committerSam Wilkins <samwilkins333@gmail.com>2020-02-02 12:47:57 -0500
commite4231a12dc7c85da95bdea7b17bb4d9bca60f12f (patch)
treed03a0468eaf94102b04f9c49a0691ba77581333e /src/Utils.ts
parent224731f36c420e45076921db1b5e39f19f775e68 (diff)
utils
Diffstat (limited to 'src/Utils.ts')
-rw-r--r--src/Utils.ts16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/Utils.ts b/src/Utils.ts
index 29fce3409..9e3db9e06 100644
--- a/src/Utils.ts
+++ b/src/Utils.ts
@@ -26,6 +26,22 @@ export namespace Utils {
return { scale, translateX, translateY };
}
+ export function TraceConsoleLog() {
+ ['log', 'warn'].forEach(function (method) {
+ const old = (console as any)[method];
+ (console as any)[method] = function () {
+ let stack = new Error("").stack?.split(/\n/);
+ // Chrome includes a single "Error" line, FF doesn't.
+ if (stack && stack[0].indexOf('Error') === 0) {
+ stack = stack.slice(1);
+ }
+ const message = (stack?.[1] || "Stack undefined!").trim();
+ const args = ([] as any[]).slice.apply(arguments).concat([message]);
+ return old.apply(console, args);
+ };
+ });
+ }
+
/**
* A convenience method. Prepends the full path (i.e. http://localhost:1050) to the
* requested extension