Loxer - v3.0.0
    Preparing search index...

    Type Alias FunctionOpenMessage<Args>

    FunctionOpenMessage:
        | ((context: TraceOpenMessageContext<Args>) => string)
        | "fn"
        | "parent.fn"
        | "fn(types)"
        | "fn(args)"
        | "parent.fn(types)"
        | "parent.fn(args)"

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

    Templates render against the traced name, and parent. prefixes it with the class a traced method belongs to, or the file a traced plain function is written in. For a method calculate(price: number, quantity: number) of class Checkout, called as calculate(19.95, 3):

    • 'fn' — calculate()
    • 'parent.fn' — Checkout.calculate() (also the default when openMessage is omitted)
    • 'fn(types)' — calculate(number, number) (typeof each argument)
    • 'fn(args)' — calculate(19.95, 3) (arguments stringified into the message)
    • 'parent.fn(types)' — Checkout.calculate(number, number)
    • 'parent.fn(args)' — Checkout.calculate(19.95, 3)

    Every template is colored in the props printer's palette: the text between the parentheses the way a string is printed, the function name and its parent the way a function and a class are. The parentheses, the separators and the done suffix stay in the color of the message around them.

    A callback receives a TraceOpenMessageContext and must return the message string. Args is inferred from the target a trace.info() marker names; pass it explicitly on trace.info<Args, Result>(options).

    Type Parameters

    • Args extends readonly unknown[] = readonly unknown[]
    import { trace } from 'loxer/trace';

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

    trace.info(calculate, {
    openMessage: ({ args: [price, quantity], parentFn }) => parentFn(`${price} × ${quantity}`),
    });
    import { trace } from 'loxer/trace';

    function calculate(price: number, quantity: number) {
    trace.info<[number, number]>({
    openMessage: ({ args: [p, q], parentFn }) => parentFn(`${p} × ${q}`),
    });
    }