Skip to content

debug fn args

awekrx edited this page May 29, 2026 · 1 revision

debug-fn-args

Import

import { debugFnArgs } from '@dev-suite/decorators/debug-fn-args'

Category

  • method

Use Case

Log method arguments in a consistent debug format.

Replaces

  • Temporary console.log(args) scattered in methods
  • Custom per-method debug wrappers

Example 1

Without decorator

class PaymentService {
  charge(amount: number, cardToken: string) {
    console.log('charge args', { amount, cardToken: cardToken.slice(0, 4) + '***' });
    return this.gateway.charge(amount, cardToken);
  }
}

With decorator

import { debugFnArgs } from '@dev-suite/decorators/debug-fn-args';

class PaymentService {
  @debugFnArgs({ label: 'payment.charge' })
  charge(amount: number, cardToken: string) {
    return this.gateway.charge(amount, cardToken);
  }
}

Why better

  • Keeps debug policy configurable without polluting method body.
  • Labeling format is standardized.

Example 2

Without decorator

class ReportService {
  run(filters: ReportFilters) {
    console.log('run filters', filters);
    return this.engine.run(filters);
  }
}

With decorator

import { debugFnArgs } from '@dev-suite/decorators/debug-fn-args';

class ReportService {
  @debugFnArgs({ formatArgs: ([filters]) => ({ range: filters.range, type: filters.type }) })
  run(filters: ReportFilters) {
    return this.engine.run(filters);
  }
}

Why better

  • Can redact/shape logs via formatter in one place.
  • Safer and more consistent than inline logging.

Clone this wiki locally