UNPKG

@snap/camera-kit

Version:
77 lines 2.8 kB
import { Subject } from "rxjs"; /** * This map associates log level names with their corresponding level value. * This means that a configured log level will match all log entries with a level value greater than * or equal to the configured value. * * @internal */ export declare const logLevelMap: Record<LogLevel, number>; /** * Initializes a new logger subject. * * Note: currently only one `CameraKit` instance is allowed to listen to log messages at a time, therefore that is * necessary to avoid sharing the same subject between multiple `CameraKit` instances by calling`resetLogger()`. * Also, `resetLogger()` should be called when there is no interest in logged messages. * This allows the previous logEntriesSubject to be GCec. * * @internal */ export declare function resetLogger(): Subject<LogEntry>; /** * @internal */ export interface LogEntry { time: Date; module: string; level: keyof Logger; messages: any[]; } /** * Defines the available logging levels for the Camera Kit SDK. * * Possible values are: * - `"error"` - Log only errors (most restrictive) * - `"warn"` - Log warnings and errors * - `"info"` - Log informational messages, warnings, and errors * - `"debug"` - Log all messages including debug information (most verbose) * * When a log level is set, all messages at that level and higher priority levels will be logged. * For example, setting the log level to `"warn"` will log warnings and errors, but not info or debug messages. */ export type LogLevel = "error" | "warn" | "info" | "debug"; /** * A logger interface that provides methods for logging messages at different severity levels. * * Each method corresponds to a {@link LogLevel} and accepts a message with optional additional parameters. * All logged messages are emitted through the internal logging subject and can be consumed by configuring * a logger in the Camera Kit configuration. */ export type Logger = Record<LogLevel, (message?: any, ...optionalParams: any[]) => void>; /** * Gets logger for a given module. * * @internal * * @param module Module name. * @returns Logger instance. */ export declare function getLogger(module: string): Logger; /** * Maps a logger configuration to a Logger instance. * * @internal * * @param logger - Either "noop" for no logging, "console" for console output, or a custom Logger instance * @returns A Logger instance * @throws Error if the provided logger instance doesn't implement all required methods */ export declare function mapLogger(logger: undefined | "noop" | "console" | Logger): Logger; /** * A no-op logger that discards all log messages. * Useful when logging should be disabled entirely. * * @internal */ export declare const noopLogger: Logger; //# sourceMappingURL=logger.d.ts.map