/** * @license * Copyright 2022-2024 Matter.js Authors * SPDX-License-Identifier: Apache-2.0 */ import type { Lifecycle } from "../util/Lifecycle.js"; import { LogLevel } from "./LogLevel.js"; /** * Logged values may implement this interface to customize presentation. * * You can use the utility functions such as {@link Diagnostic.dict} to create * Diagnostics from common value types. */ export interface Diagnostic { readonly [Diagnostic.presentation]?: Diagnostic.Presentation | Lifecycle.Status; readonly [Diagnostic.value]?: unknown; } /** * Create a diagnostic giving a value a specific presentation. */ export declare function Diagnostic(presentation: Diagnostic.Presentation | Lifecycle.Status, value: unknown): Diagnostic; export declare namespace Diagnostic { enum Presentation { /** * Render an object as a log message. */ Message = "message", /** * By default iterables render as a single line with spaces separating. The "list" presentation treats elements * instead as separate entities which typically means presentation on different lines. * * Within an iterable, a list also serves to present contained items as subordinate to the previous item. */ List = "list", /** * Render iterables without intervening spaces. */ Squash = "squash", /** * An emphasized diagnostic. Rendered to draw attention. */ Strong = "strong", /** * A deemphasized diagnostic. Rendered to draw less attention than default rendering. */ Weak = "weak", /** * An error message diagnostic. */ Error = "error", /** * A key/value diagnostic. Rendered as a group of key/value pairs. */ Dictionary = "dictionary", /** * Path, resource or session identifier. */ Via = "via" } const presentation: unique symbol; const value: unique symbol; interface Message { [presentation]?: Presentation.Message; now: Date; level: LogLevel; facility: string; prefix: string; values: unknown[]; } /** * Create an object representing a log message. */ function message(value: Partial): Message; /** * Create a value presented emphatically. */ function strong(value: unknown): Diagnostic; /** * Create a value presented less emphatically than the default. */ function weak(value: unknown): Diagnostic; /** * Create a value identifying the source of a diagnostic event. */ function via(value: string): string; /** * A node in a diagnostic tree. Top-level diagnostic sources registered with DiagnosticSource should present as * nodes. */ function node(icon: string, label: unknown, detail: { self?: unknown; children?: unknown[]; }): unknown[]; /** * Create a value presenting as a list of separate lines. */ function list(value: Iterable): Diagnostic; /** * Create a value presenting as segments of the same string without intervening spaces. */ function squash(...values: unknown[]): Diagnostic; /** * Create a K/V map that presents with formatted keys. */ function dict(entries: object): Record & Diagnostic; /** * Create a Diagnostic for an error. */ function error(error: any): string | Diagnostic; /** * Create a diagnostic with a specific {@link Lifecycle}. */ function lifecycle(status: Lifecycle.Status, value: unknown): Diagnostic; /** * Create a diagnostic for a {@link Lifecycle.Map}. */ function lifecycleList(map: Lifecycle.Map): Diagnostic[]; interface Elapsed { readonly startedAt: number; readonly time: number; toString(): string; } /** * Convert an interval to text. */ function interval(ms: number): string; /** * Create a diagnostic that renders as elapsed time since creation. */ function elapsed(): Elapsed; /** * Upgrade a value to support specialized diagnostic rendering. */ function upgrade(value: boolean | number | string | object, diagnostic: unknown): T; /** * Convert a number or bigint to a hex string which is prefixed by "0x" for logging purposes */ function hex(value: number | bigint): string; } //# sourceMappingURL=Diagnostic.d.ts.map