@kwiz/common
Version:
KWIZ common utilities and helpers for M365 platform
65 lines (64 loc) • 2.91 kB
TypeScript
import { releasetypes } from './types/common.types';
import { ConsoleLogger, logMessageValue } from './utils/consolelogger';
export interface iConfigInfo {
BuildNumber: string;
IsLocalDev: boolean;
IsFastRing: boolean;
IsProduction: boolean;
ReleaseStatus: releasetypes;
ProjectName: string;
}
/** @deprecated should only be used for 3rd party packages. main project must call config and mark it as sideEffects */
export declare class CommonConfig {
private constructor();
static get i(): iConfigInfo;
}
/** @deprecated should only be used for 3rd party packages. main project must call config and mark it as sideEffects */
export declare class CommonLogger {
private name;
constructor(name: string);
private instance;
get i(): ConsoleLogger;
debug(message: any): void;
info(message: any): void;
log(message: any): void;
/** output a message when debug is off */
warn(message: any): void;
/** output a message when debug is off */
error(message: any): void;
/** output a message when debug is off */
trace(message: any): void;
/**start timer on a label, call timeEnd with the same label to print out the time that passed */
time(label: string): void;
/**start timer on a label, call timeEnd with the same label to print out the time that passed */
timeEnd(label: string): void;
/**prints an array or dictionary to the console inside a group */
table(data: any, groupLabel?: string, groupCollapsed?: boolean): void;
/**prints a JSON object to the console inside a group */
json(data: any, groupLabel?: string, groupCollapsed?: boolean): void;
/**prints an XML object to the console inside a group. If data is string that looks like an XML - will try to parse it. */
xml(data: any, groupLabel?: string, groupCollapsed?: boolean): void;
/** render messages inside a group, and closes the group when done. if a label is not provided - a group will not be rendered */
group(renderContent: () => void, label?: string, collapsed?: boolean): void;
groupSync<ReturnType>(label: string, renderContent: (log: (message: logMessageValue) => void) => ReturnType, options?: {
expand?: boolean;
/** do not write to log */
supress?: boolean;
}): ReturnType;
groupAsync<ReturnType>(label: string, renderContent: (log: (message: logMessageValue) => void) => Promise<ReturnType>, options?: {
expand?: boolean;
/** do not write to log */
supress?: boolean;
}): Promise<ReturnType>;
}
export interface iConfigParams {
BuildNumber: string;
ReleaseStatus: releasetypes;
ProjectName: string;
}
export declare function config(params: iConfigParams): {
GetLogger: (name: string) => ConsoleLogger;
/** @deprecated call GetLogger instead */
logger: (name: string) => ConsoleLogger;
configInfo: iConfigInfo;
};