configcat-common
Version:
ConfigCat is a configuration as a service that lets you manage your features and configurations without actually deploying new code.
100 lines • 5.29 kB
TypeScript
import type { SafeHooksWrapper } from "./Hooks";
/**
* Specifies event severity levels for the `IConfigCatLogger` interface.
* The levels are interpreted as minimum levels in the case of event filtering.
*/
export declare enum LogLevel {
/** All events are logged. */
Debug = 4,
/** Info, Warn and Error are logged. Debug events are discarded. */
Info = 3,
/** Warn and Error events are logged. Info and Debug events are discarded. */
Warn = 2,
/** Error events are logged. All other events are discarded. */
Error = 1,
/** No events are logged. */
Off = -1
}
export declare type LogEventId = number;
/** Represents a log message format with named arguments. */
export declare class FormattableLogMessage {
readonly strings: ReadonlyArray<string>;
readonly argNames: ReadonlyArray<string>;
readonly argValues: ReadonlyArray<unknown>;
static from(...argNames: string[]): (strings: TemplateStringsArray, ...argValues: unknown[]) => FormattableLogMessage;
private cachedDefaultFormattedMessage?;
constructor(strings: ReadonlyArray<string>, argNames: ReadonlyArray<string>, argValues: ReadonlyArray<unknown>);
get defaultFormattedMessage(): string;
toString(): string;
}
export declare type LogMessage = string | FormattableLogMessage;
/** Defines the interface used by the ConfigCat SDK to perform logging. */
export interface IConfigCatLogger {
/** Gets the log level (the minimum level to use for filtering log events). */
readonly level?: LogLevel;
/** Gets the character sequence to use for line breaks in log messages. Defaults to "\n". */
readonly eol?: string;
/**
* Writes an event into the log.
* @param level Event severity level.
* @param eventId Event identifier.
* @param message Message.
* @param exception The exception object related to the message (if any).
*/
log(level: LogLevel, eventId: LogEventId, message: LogMessage, exception?: any): void;
}
export declare class LoggerWrapper implements IConfigCatLogger {
private readonly logger;
private readonly hooks?;
get level(): LogLevel;
get eol(): string;
constructor(logger: IConfigCatLogger, hooks?: SafeHooksWrapper | undefined);
isEnabled(logLevel: LogLevel): boolean;
/** @inheritdoc */
log(level: LogLevel, eventId: LogEventId, message: LogMessage, exception?: any): LogMessage;
/**
* Shorthand method for `logger.logEvent(LogLevel.Debug, 0, message);`
*/
debug(message: string): void;
configJsonIsNotPresent(defaultReturnValue: string): LogMessage;
configJsonIsNotPresentSingle(key: string, defaultParamName: string, defaultParamValue: unknown): LogMessage;
settingEvaluationFailedDueToMissingKey(key: string, defaultParamName: string, defaultParamValue: unknown, availableKeys: string): LogMessage;
settingEvaluationError(methodName: string, defaultReturnValue: string, ex: any): LogMessage;
settingEvaluationErrorSingle(methodName: string, key: string, defaultParamName: string, defaultParamValue: unknown, ex: any): LogMessage;
forceRefreshError(methodName: string, ex: any): LogMessage;
fetchFailedDueToInvalidSdkKey(): LogMessage;
fetchFailedDueToUnexpectedHttpResponse(statusCode: number, reasonPhrase: string): LogMessage;
fetchFailedDueToRequestTimeout(timeoutMs: number, ex: any): LogMessage;
fetchFailedDueToUnexpectedError(ex: any): LogMessage;
fetchFailedDueToRedirectLoop(): LogMessage;
fetchReceived200WithInvalidBody(ex: any): LogMessage;
fetchReceived304WhenLocalCacheIsEmpty(statusCode: number, reasonPhrase: string): LogMessage;
autoPollConfigServiceErrorDuringPolling(ex: any): LogMessage;
settingForVariationIdIsNotPresent(variationId: string): LogMessage;
configServiceCacheReadError(ex: any): LogMessage;
configServiceCacheWriteError(ex: any): LogMessage;
clientIsAlreadyCreated(sdkKey: string): LogMessage;
userObjectIsMissing(key: string): LogMessage;
dataGovernanceIsOutOfSync(): LogMessage;
userObjectAttributeIsMissingPercentage(key: string, attributeName: string): LogMessage;
userObjectAttributeIsMissingCondition(condition: string, key: string, attributeName: string): LogMessage;
userObjectAttributeIsInvalid(condition: string, key: string, reason: string, attributeName: string): LogMessage;
userObjectAttributeIsAutoConverted(condition: string, key: string, attributeName: string, attributeValue: string): LogMessage;
configServiceCannotInitiateHttpCalls(): LogMessage;
configServiceMethodHasNoEffectDueToDisposedClient(methodName: string): LogMessage;
configServiceMethodHasNoEffectDueToOverrideBehavior(overrideBehavior: string, methodName: string): LogMessage;
settingEvaluated(evaluateLog: string): LogMessage;
configServiceStatusChanged(status: string): LogMessage;
}
export declare class ConfigCatConsoleLogger implements IConfigCatLogger {
level: LogLevel;
readonly eol: string;
SOURCE: string;
/**
* Create an instance of ConfigCatConsoleLogger
*/
constructor(level?: LogLevel, eol?: string);
/** @inheritdoc */
log(level: LogLevel, eventId: LogEventId, message: LogMessage, exception?: any): void;
}
//# sourceMappingURL=ConfigCatLogger.d.ts.map