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}`),
});
}
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 methodcalculate(price: number, quantity: number)of classCheckout, called ascalculate(19.95, 3):'fn'—calculate()'parent.fn'—Checkout.calculate()(also the default whenopenMessageis omitted)'fn(types)'—calculate(number, number)(typeofeach 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
donesuffix stay in the color of the message around them.A callback receives a TraceOpenMessageContext and must return the message string.
Argsis inferred from the target atrace.info()marker names; pass it explicitly ontrace.info<Args, Result>(options).