/** * @license * Copyright 2022-2026 Matter.js Authors * SPDX-License-Identifier: Apache-2.0 */ import { Diagnostic } from "./Diagnostic.js"; import { LogDestination } from "./LogDestination.js"; import { LogFormat } from "./LogFormat.js"; import { LogLevel } from "./LogLevel.js"; /** * matter.js logging API * * Usage: * * const logger = Logger.get("loggerName"); * logger.debug("My debug message", "my extra value to log"); * * matter.js writes logs to each {@link LogDestination} in {@link Logger.destinations}. By default a single destination * named "default" writes to the JS console. * * You may adjust log verbosity and format by modifying the properties on destinations. For example: * * `Logger.format = LogFormat.PLAIN` sets all destinations to write plaintext * `Logger.destinations.default.format = LogFormat.format.ansi` sets one destination to write ANSI * `Logger.level = LogLevel.NOTICE` sets "notice" as the minimum level for all destinations * `Logger.destinations.default.level = LogLevel.NOTICE` sets "notice" as level for one destination */ export declare class Logger { #private; /** * Log destinations. * * By default there is a single destination named "default". You can create new destinations using * {@link LogDestination}. Add or remove destinations by modifying this object. * * Throws an error if you access a destination that doesn't exist. */ static destinations: Record; /** * The number of indents to print with messages. */ static nestingLevel: number; /** * Create a new logger for a facility. * * @param name the name of the facility * @returns a new facility */ static get(name: string): Logger; /** * Get the default log level. */ static get level(): LogLevel | string; /** * Set log level as name or number for all destinations. */ static set level(level: LogLevel | string); /** * Get the default facility levels. */ static get facilityLevels(): Record; /** * Set log level as name or number for facilities in all destinations. * * Existing levels that are not named in {@link levels} will remain unchanged. */ static set facilityLevels(levels: Record); /** * Get the default format name. */ static get format(): string; /** * Set the format for all destinations. */ static set format(format: string | LogFormat.Formatter); /** * Mask a string with a given character. If unmaskedLength is provided then these number of characters will be * shown unmasked. * * @param str String to mask * @param maskChar character to mask with * @param unmaskedLength number of characters to show unmasked in the beginning */ static maskString(str: string, maskChar?: string, unmaskedLength?: number): string; /** * Perform operations in a nested logging context. Messages will be * indented while the context executes. */ static nest(context: () => T): T; /** * Async version of nest(). */ static nestAsync(context: () => Promise): Promise; /** * Unhandled error reporter. * * Some environments do not report full error details such as {@link Error#cause} and {@link AggregateError#errors}. * * To ensure these details are always recorded somewhere, unhandled errors may be reported here. * * To disable this behavior replace this function. */ static reportUnhandledError(error: Error): void; constructor(name: string); debug(...values: unknown[]): void; info(...values: unknown[]): void; notice(...values: unknown[]): void; warn(...values: unknown[]): void; error(...values: unknown[]): void; fatal(...values: unknown[]): void; log(level: LogLevel, ...values: unknown[]): void; /** * Stringify a value (BigInt aware) as JSON. * * @param data the value to stringify * @returns the stringified value * * @deprecated use {@link Diagnostic.json} */ static toJSON(data: any): string; /** * Add additional logger to the list of loggers including the default configuration. * * @deprecated use {@link destinations} */ static addLogger(identifier: string, logger: (level: LogLevel, formattedLog: string) => void, options?: { defaultLogLevel?: LogLevel; logLevels?: { [facility: string]: LogLevel; }; logFormat?: string; }): void; /** * @deprecated use {@link destinations} */ static removeLogger(identifier: string): void; /** * Check if a logger with the matching identifier exists. * @param identifier The identifier of the logger * * @deprecated use {@link destinations} */ static hasLoggerForIdentifier(identifier: string): boolean; /** * Get the logger with the matching identifier. * @param identifier The identifier of the logger * * @deprecated use {@link destinations} */ static getLoggerForIdentifier(identifier: string): LoggerDefinition; /** * @deprecated use {@link destinations} */ static getLoggerforIdentifier(identifier: string): LoggerDefinition; /** * Set facility loglevels for the default logger. * @param levels The levels to set * * @deprecated use {@link destinations} */ static set logLevels(levels: { [facility: string]: LogLevel; }); /** * Get facility loglevels for the default logger. * * @deprecated use {@link Logger.facilityLevels} */ static get logLevels(): { [facility: string]: LogLevel; }; /** * Set default loglevel for the default logger. * * @param level The level to set * * @deprecated use {@link Logger.level} */ static set defaultLogLevel(level: LogLevel); /** * Get default loglevel for the default logger. * * @deprecated use {@link destinations} */ static get defaultLogLevel(): LogLevel; /** * Set the log function for the default logger. * * @param log The log function to set * * @deprecated use {@link destinations} */ static set log(log: (level: LogLevel, formattedLog: string, facility?: string) => void); /** * Get the log function for the default logger. * * @deprecated use {@link destinations} */ static get log(): (level: LogLevel, formattedLog: string, facility?: string) => void; /** * Set the log formatter for the default logger. * * @param logFormatter * * @deprecated use {@link destinations} */ static set logFormatter(logFormatter: (now: Date, level: LogLevel, facility: string, nestingPrefix: string, values: any[]) => string); /** * Get the log formatter for the default logger. * * @deprecated use {@link destinations} */ static get logFormatter(): (now: Date, level: LogLevel, facility: string, nestingPrefix: string, values: any[]) => string; /** * Set logFormatter using configuration-style format name for the logger with the matching identifier. * * @param identifier The identifier of the logger * @param format the name of the formatter (see Format enum) * * @deprecated use {@link destinations} */ static setFormatForLogger(identifier: string, format: string): void; /** * Set default loglevel for the logger with the matching identifier. * * @param identifier The identifier of the logger * @param level The level to set * * @deprecated use {@link destinations} */ static setDefaultLoglevelForLogger(identifier: string, level: LogLevel): void; /** * Set facility loglevels for the logger with the matching identifier. * * @param identifier The identifier of the logger * @param levels The levels to set * * @deprecated use {@link destinations} */ static setLogLevelsForLogger(identifier: string, levels: { [facility: string]: LogLevel; }): void; /** * Set the log function for the logger with the matching identifier. * * @param identifier The identifier of the logger * @param log The log function to set * * @deprecated use {@link destinations} */ static setLogger(identifier: string, log: (level: LogLevel, formattedLog: string, facility?: string) => void): void; /** * Set the log formatter for the logger with the matching identifier. * * @param identifier The identifier of the logger * @param logFormatter The log formatter to set * * @deprecated use {@link destinations} */ static setLogFormatterForLogger(identifier: string, logFormatter: (now: Date, level: LogLevel, facility: string, nestingPrefix: string, values: any[]) => string): void; } /** * Definition of one registered Logger. * * @deprecated */ type LoggerDefinition = { logIdentifier: string; logFormatter: (now: Date, level: LogLevel, facility: string, prefix: string, values: any[]) => string; log: (level: LogLevel, formattedLog: string, facility?: string) => void; defaultLogLevel: LogLevel; logLevels: { [facility: string]: LogLevel; }; context?: Diagnostic.Context; }; export {}; //# sourceMappingURL=Logger.d.ts.map