@itwin/presentation-common
Version:
Common pieces for iModel.js presentation packages
125 lines • 3.82 kB
TypeScript
/** @packageDocumentation
* @module Core
*/
/**
* Type of diagnostics logger severity.
* @public
*/
export type DiagnosticsLoggerSeverity = "error" | "warning" | "info" | "debug" | "trace";
/**
* Returns lower severity of the given two. Examples:
* ```
* combineDiagnosticsSeverities("error", "error") === "error"
* combineDiagnosticsSeverities("error", "debug") === "debug"
* combineDiagnosticsSeverities("debug", "error") === "debug"
* ```
* @internal
*/
export declare function combineDiagnosticsSeverities(lhs: undefined | boolean | DiagnosticsLoggerSeverity, rhs: undefined | boolean | DiagnosticsLoggerSeverity): DiagnosticsLoggerSeverity | undefined;
/**
* Returns 0 if the given severities are equal after normalization, negative if `lhs` is lower, positive if higher. Examples:
* ```
* compareDiagnosticsSeverities("error", "error") === 0
* compareDiagnosticsSeverities("error", false) === 0
* compareDiagnosticsSeverities("error", undefined) === 0
* compareDiagnosticsSeverities("debug", true) === 0
* compareDiagnosticsSeverities("debug", "error") < 0
* compareDiagnosticsSeverities("error", "debug") > 0
* ```
* @internal
*/
export declare function compareDiagnosticsSeverities(lhs: undefined | boolean | DiagnosticsLoggerSeverity, rhs: undefined | boolean | DiagnosticsLoggerSeverity): 0 | 1 | -1;
/**
* Data structure for diagnostics information.
* @public
*/
export interface Diagnostics {
logs?: DiagnosticsScopeLogs[];
}
/**
* Data structure with client diagnostics information.
* @public
*/
export interface ClientDiagnostics extends Diagnostics {
backendVersion?: string;
}
/**
* Data structure for diagnostics options.
* @public
*/
export interface DiagnosticsOptions {
/**
* Flag specifying that performance should be measured, or
* minimum duration in milliseconds for which performance metric should be included.
*/
perf?: boolean | {
minimumDuration: number;
};
/** Severity for developer log messages */
dev?: boolean | DiagnosticsLoggerSeverity;
/** Severity for presentation rules' editor log messages */
editor?: boolean | DiagnosticsLoggerSeverity;
}
/**
* A function that can be called after receiving diagnostics.
* @public
*/
export type ClientDiagnosticsHandler = (logs: ClientDiagnostics) => void;
/**
* Data structure for client diagnostics options.
* @public
*/
export interface ClientDiagnosticsOptions extends DiagnosticsOptions {
backendVersion?: boolean;
handler: ClientDiagnosticsHandler;
}
/**
* Data structure which contains client diagnostics options.
* @public
*/
export interface ClientDiagnosticsAttribute {
/**
* Diagnostics options.
*/
diagnostics?: ClientDiagnosticsOptions;
}
/**
* Data structure for diagnostics log message information.
* @public
*/
export interface DiagnosticsLogMessage {
severity: {
dev?: DiagnosticsLoggerSeverity;
editor?: DiagnosticsLoggerSeverity;
};
category: string;
message: string;
timestamp: number;
}
/**
* Data structure for diagnostics scope information.
* @public
*/
export interface DiagnosticsScopeLogs {
scope: string;
scopeCreateTimestamp?: number;
duration?: number;
logs?: DiagnosticsLogEntry[];
attributes?: {
[attributeKey: string]: string | string[];
};
}
/**
* Data structure for diagnostics log entry.
* @public
*/
export type DiagnosticsLogEntry = DiagnosticsLogMessage | DiagnosticsScopeLogs;
/**
* Functions related to diagnostics log entry.
* @public
*/
export declare namespace DiagnosticsLogEntry {
function isMessage(entry: DiagnosticsLogEntry): entry is DiagnosticsLogMessage;
function isScope(entry: DiagnosticsLogEntry): entry is DiagnosticsScopeLogs;
}
//# sourceMappingURL=Diagnostics.d.ts.map