lit-ui-router-ssr / lit-ui-router-ssr / registerTraceCategory
Function: registerTraceCategory()
function registerTraceCategory(router, name): void;Defined in: packages/lit-ui-router-ssr/src/trace-categories.ts:123
Registers a trace category beyond core's fixed set, so router.trace.enable(name), disable(name) and enabled(name) switch it alone, and a no-argument enable() or disable() covers it too.
Core normalizes every category name through its Category enum, so on its own an unknown name lands on one shared undefined key, and enabling any unknown name reads every other as enabled. This installs, once per router, a wrapper over router.trace that answers registered names itself and forwards everything else to core's trace. Core's own code logs through the imported trace singleton, which the wrapper leaves untouched. Registered names are kept per underlying trace, so every router registered over core's singleton agrees on them; a router that never registers reads core's trace unwrapped, and core's imported trace.disable() leaves registered names on.
When router.trace has a registerCategory of its own, this delegates to it and installs nothing.
Register before enabling: call it right after creating the router.
Parameters
| Parameter | Type | Description |
|---|---|---|
router | UIRouter | the router whose trace gains the category |
name | string | the category's name, such as 'HYDRATION' |
Returns
void
Throws
an Error for one of core's own category names, such as 'TRANSITION'
Example
import { UIRouterLit } from 'lit-ui-router';
import { registerTraceCategory } from 'lit-ui-router-ssr/client';
const router = new UIRouterLit();
registerTraceCategory(router, 'HYDRATION');
router.trace.enable('HYDRATION');