MCPcopy Index your code
hub / github.com/material-shell/material-shell / addLogToFunctions

Method addLogToFunctions

src/utils/debug.ts:90–125  ·  view source on GitHub ↗
(prototype: any)

Source from the content-addressed store, hash-verified

88 }
89
90 addLogToFunctions(prototype: any) {
91 if (!DEBUG) return;
92 for (const key of Object.getOwnPropertyNames(prototype)) {
93 if (key === 'constructor') continue;
94 const descriptor = Object.getOwnPropertyDescriptor(prototype, key);
95 if (descriptor) {
96 const value = descriptor.value;
97 if (typeof value === 'function') {
98 prototype[key] = function (...args: any[]) {
99 // Before
100 Debug.log(
101 `${prototype.constructor.name}.${key} (${Array.from(
102 args
103 )
104 .map((param) => {
105 try {
106 return param.toString();
107 } catch (_e) {
108 return '';
109 }
110 })
111 .join(',')})`
112 );
113 indent++;
114 try {
115 const result = value.apply(this, args); // use .apply() to call it
116 // After
117 return result;
118 } finally {
119 indent--;
120 }
121 };
122 }
123 }
124 }
125 }
126}

Callers 1

constructorMethod · 0.95

Calls 5

joinMethod · 0.80
applyMethod · 0.80
logMethod · 0.65
mapMethod · 0.65
toStringMethod · 0.45

Tested by

no test coverage detected