UNPKG

dazscript-framework

Version:

The **DazScript Framework** is a TypeScript-based framework for writing Daz Studio scripts. It provides all the advantages of a typed language such as autocompletion, error checking, and method parameter documentation and hinting. The framework also inclu

27 lines (23 loc) 955 B
import { app } from '@dsf/core/global'; export function trace(enabled: boolean = true) { return function (target: any, key?: string, descriptor?: PropertyDescriptor) { if (key !== undefined && descriptor !== undefined) { // Applied to a method if (!enabled) return descriptor const originalMethod = descriptor.value; descriptor.value = function (...args: any[]) { app.debug(`[TRACE] Entering method: ${key}`); app.flushLogBuffer() const result = originalMethod.apply(this, args); app.debug(`[TRACE] Exiting method: ${key}`); app.flushLogBuffer() return result; }; return descriptor; } else if (key === undefined && descriptor === undefined) { // Applied to a class return target; } } }