Loxer - v3.0.0
    Preparing search index...

    Type Alias FunctionCloseMessage<Result>

    FunctionCloseMessage:
        | ((context: TraceCloseMessageContext<Result>) => string)
        | "fn"
        | "parent.fn"
        | "fn(result)"
        | "parent.fn(result)"

    How the successful closing box message is built for trace.info().

    Templates render against the traced name, and parent. prefixes it the way FunctionOpenMessage describes. For async targets the message uses the resolved (awaited) result, not the Promise. For a method calculate of class Checkout returning { total: 59.85 }:

    • 'fn' — calculate done (also the default when closeMessage is omitted)
    • 'parent.fn' — Checkout.calculate done
    • 'fn(result)' — calculate({"total":59.85}) done (JSON.stringify)
    • 'parent.fn(result)' — Checkout.calculate({"total":59.85}) done

    A result that does not serialize — a void function's, most of all — reports the 'fn' / 'parent.fn' message of the same name form instead of a payload.

    A callback receives a TraceCloseMessageContext and must return the message string. Result is inferred from the target a trace.info() marker names; pass it explicitly on trace.info<Args, Result>(options). A failed call closes with … failed in the name form this option selects, and never reaches a callback.

    Type Parameters

    • Result = unknown
    import { trace } from 'loxer/trace';

    function calculate(price: number, quantity: number) { ... }

    trace.info(calculate, { closeMessage: 'fn(result)' });
    import { trace } from 'loxer/trace';

    trace.info(calculate, {
    closeMessage: ({ result, fn }) => fn(result.total.toFixed(2)),
    });