@kwiz/common
Version:
KWIZ common utilities and helpers for M365 platform
79 lines (78 loc) • 3.09 kB
TypeScript
export declare enum LoggerLevel {
VERBOSE = 0,
DEBUG = 1,
INFO = 2,
LOG = 3,
/** shows when debug=off */
WARN = 4,
/** shows when debug=off */
TRACE = 5,
/** shows when debug=off */
ERROR = 6,
OFF = 10
}
export type LoggerContext = {
filterLevel?: LoggerLevel;
name?: string;
prefix?: string;
};
type logMessageValue = string | {
label: string;
value: Object;
};
export declare class ConsoleLogger {
context: LoggerContext;
protected constructor(context: LoggerContext);
static get(name: string, prefix?: string): ConsoleLogger;
private static _getGlobal;
private static _getDefaultLogger;
static setLevel(newLevel: LoggerLevel): void;
static getLevel(): LoggerLevel;
static debug(message: string): void;
static info(message: string): void;
static log(message: string): void;
static warn(message: string): void;
static error(message: string): void;
static trace(message: string): void;
static commonPrefix(prefix?: string): string;
private contextPrefix;
private format;
setLevel(newLevel: LoggerLevel): void;
getLevel(): LoggerLevel;
enabledFor(level: LoggerLevel): boolean;
debug(message: any): void;
info(message: string): void;
log(message: string): void;
/** output a message when debug is off */
warn(message: string): void;
/** output a message when debug is off */
error(message: string): void;
/** output a message when debug is off */
trace(message: string): 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>;
private $startGroup;
private $finishGroup;
private logWithLevel;
}
export {};