@microsoft/windows-admin-center-sdk
Version:
Microsoft - Windows Admin Center Shell
304 lines (303 loc) • 13.8 kB
TypeScript
import { GatewayConnection } from '../data/gateway-connection';
import { Rpc } from '../rpc/rpc';
import { LogLevel } from './log-level';
import { LogRecord } from './log-record';
import { TelemetryControlType } from './telemetry-control-type';
import { TelemetryRecord } from './telemetry-record';
/**
* Logging class.
* @dynamic
*/
export declare class Logging {
private static logMaxRecordLength;
private static logMaxWaitTimeMs;
private static telemetryMaxRecordLength;
private static telemetryMaxWaitTimeMs;
private static testMode;
private static instance;
private static errorLogHeaderStyle;
private static warnLogHeaderStyle;
private static successLogHeaderStyle;
private static infoLogHeaderStyle;
private static verboseLogHeaderStyle;
private logSubjectServer;
private telemetrySubjectServer;
private gateway;
private http;
private rpc;
private logSet;
private telemetrySet;
private thresholdOfLogLevel;
private verboseTelemetry;
/**
* Log a logging event.
*
* @param record the log record to send the gateway.
* @return Promise<any> settle to resolve if buffered.
*/
static log(record: LogRecord): Promise<any>;
/**
* Log a critical logging event.
*
* @param source The record originator of event within a module.
* @param message The message of event.
* @param params The parameters object which will be serialized.
* @return Promise<any> settle to resolve if buffered.
*/
static logCritical(source: string, message: string, params?: any): Promise<any>;
/**
* Log an error logging event.
*
* @param source The record originator of event within a module.
* @param message The message of event.
* @param params The parameters object which will be serialized.
* @return Promise<any> settle to resolve if buffered.
*/
static logError(source: string, message: string, params?: any): Promise<any>;
/**
* Log a warning logging event.
*
* @param source The record originator of event within a module.
* @param message The message of event.
* @param params The parameters object which will be serialized.
* @return Promise<any> settle to resolve if buffered.
*/
static logWarning(source: string, message: string, params?: any): Promise<any>;
/**
* Log a success logging event.
*
* @param source The record originator of event within a module.
* @param message The message of event.
* @param params The parameters object which will be serialized.
* @return Promise<any> settle to resolve if buffered.
*/
static logSuccess(source: string, message: string, params?: any): Promise<any>;
/**
* Log a informational logging event.
*
* @param source The record originator of event within a module.
* @param message The message of event.
* @param params The parameters object which will be serialized.
* @return Promise<any> settle to resolve if buffered.
*/
static logInformational(source: string, message: string, params?: any): Promise<any>;
/**
* Log a verbose logging event.
*
* @param source The record originator of event within a module.
* @param message The message of event.
* @param params The parameters object which will be serialized.
* @return Promise<any> settle to resolve if buffered.
*/
static logVerbose(source: string, message: string, params?: any): Promise<any>;
/**
* Log a debug logging event.
*
* @param source The record originator of event within a module.
* @param message The message of event.
* @param params The parameters object which will be serialized.
* @return Promise<any> settle to resolve if buffered.
*/
static logDebug(source: string, message: string, params?: any): Promise<any>;
/**
* Trace a telemetry event.
*
* @param record the telemetry record to send the gateway.
* @return Promise<any> settle to resolve if buffered.
*/
static trace(record: TelemetryRecord): Promise<any>;
/**
* Trace a user action telemetry event.
*
* @param data additional data.
* @return Promise<any> settle to resolve if buffered.
*/
static traceUserAction(data: any): Promise<any>;
/**
* Trace a telemetry event for a button click.
*
* @param controlName Describes which control was used.
* ex) For a button that says 'Set up' the control name can be 'Set up' to distinguish that from a cancel button.
* @param controlId Unique identifier when a control appears more than once. Specific to how implementation handles uniqueness.
* @param nodeName the name of the node currently connected to (this.appContextService.activeConnection.nodeName)
* @param nodeType the type of node currently connected to (this.appContextService.connectionManager.activeConnection.type)
* @return Promise<any> settle to resolve if buffered.
*/
static traceButton(controlName: string, controlId?: string, nodeName?: string, nodeType?: string): Promise<any>;
/**
* Trace a telemetry event for a action pane button click.
*
* @param controlName Describes which control was used.
* ex) For a button that says 'Set up' the control name can be 'Set up' to distinguish that from a cancel button.
* @param controlId Unique identifier when a control appears more than once. Specific to how implementation handles uniqueness.
* @param nodeName the name of the node currently connected to (this.appContextService.activeConnection.nodeName)
* @param nodeType the type of node currently connected to (this.appContextService.connectionManager.activeConnection.type)
* @return Promise<any> settle to resolve if buffered.
*/
static traceActionPaneButton(controlName: string, controlId?: string, nodeName?: string, nodeType?: string): Promise<any>;
/**
* Trace a telemetry event for a action bar button click.
*
* @param controlName Describes which control was used.
* ex) For a button that says 'Set up' the control name can be 'Set up' to distinguish that from a cancel button.
* @param controlId Unique identifier when a control appears more than once. Specific to how implementation handles uniqueness.
* @param nodeName the name of the node currently connected to (this.appContextService.activeConnection.nodeName)
* @param nodeType the type of node currently connected to (this.appContextService.connectionManager.activeConnection.type)
* @return Promise<any> settle to resolve if buffered.
*/
static traceActionBarButton(controlName: string, controlId?: string, nodeName?: string, nodeType?: string): Promise<any>;
/**
* Trace a telemetry event on a sme control.
*
* @param controlName Describes which control was used.
* ex) For a button that says 'Set up' the control name can be 'Set up' to distinguish that from a cancel button.
* @param controlId Unique identifier when a control appears more than once. Specific to how implementation handles uniqueness.
* @param additionalData Additional key value pairs that can be sent to telemetry.
* @param nodeName the name of the node currently connected to (this.appContextService.activeConnection.nodeName)
* @param nodeType the type of node currently connected to (this.appContextService.connectionManager.activeConnection.type)
* @return Promise<any> settle to resolve if buffered.
*/
static traceControl(controlType: TelemetryControlType, controlName: string, controlId?: string, additionalData?: any, nodeName?: string, nodeType?: string): Promise<any>;
/**
* Trace a telemetry event on click of an external link.
*
* @param controlName Describes which control was used.
* ex) For a button that says 'Set up' the control name can be 'Set up' to distinguish that from a cancel button.
* @param url External link that was clicked.
* @param controlId Unique identifier when a control appears more than once. Specific to how implementation handles uniqueness.
* @param nodeName the name of the node currently connected to (this.appContextService.activeConnection.nodeName)
* @param nodeType the type of node currently connected to (this.appContextService.connectionManager.activeConnection.type)
* @return Promise<any> settle to resolve if buffered.
*/
static traceExternalLink(controlName: string, url: string, controlId?: string, nodeName?: string, nodeType?: string): Promise<any>;
/**
* Trace a telemetry event on click of an internal link.
*
* @param controlName Describes which control was used.
* ex) For a button that says 'Set up' the control name can be 'Set up' to distinguish that from a cancel button.
* @param route rpc route.
* @param controlId Unique identifier when a control appears more than once. Specific to how implementation handles uniqueness.
* @param nodeName the name of the node currently connected to (this.appContextService.activeConnection.nodeName)
* @param nodeType the type of node currently connected to (this.appContextService.connectionManager.activeConnection.type)
* @return Promise<any> settle to resolve if buffered.
*/
static traceInternalLink(controlName: string, route: string, controlId?: string, nodeName?: string, nodeType?: string): Promise<any>;
/**
* Trace a telemetry event when an async task returns.
*
* @param eventLocation UI location of the event being recorded.
* ex) createVmForm, RegisterAadDialog, stopServiceConfirmationDialog...
* @param eventLabel Description of what event is being logged.
* ex) 'Registered with Azure', 'Added a connection', 'Failed Azure backup'
* @param result Result of event.
* @param additionalData Additional key value pairs that can be sent to telemetry.
* @param nodeName the name of the node currently connected to (this.appContextService.activeConnection.nodeName)
* @param nodeType the type of node currently connected to (this.appContextService.connectionManager.activeConnection.type)
* @return Promise<any> settle to resolve if buffered.
*/
static traceAsyncResult(eventLocation: string, eventLabel: string, result: 'Success' | 'Error' | 'Failure', additionalData?: any, nodeName?: string, nodeType?: string): Promise<any>;
/**
* Log a raw object into the console at debug level of mode.
*/
static debug(object: any): void;
/**
* Configure logging mode.
*
* @param thresholdOfLogLevel the log level for gateway.
* @param verboseTelemetry if true, optional telemerty will be collected.
*/
static configureLog(thresholdOfLogLevel: LogLevel, verboseTelemetry: boolean): void;
/**
* Wrapper method for tracing a telemetry event for a button click.
*
* @param controlType Type of button that is being recorded
* @param controlName Describes which control was used.
* ex) For a button that says 'Set up' the control name can be 'Set up' to distinguish that from a cancel button.
* @param controlId Unique identifier when a control appears more than once. Specific to how implementation handles uniqueness.
* @param nodeName the name of the node currently connected to (this.appContextService.activeConnection.nodeName)
* @param nodeType the type of node currently connected to (this.appContextService.connectionManager.activeConnection.type)
* @return Promise<any> settle to resolve if buffered.
*/
private static traceButtonClick;
/**
* Format node information for telemetry
*
* @param nodeName the name of the node currently connected to (this.appContextService.activeConnection.nodeName)
* @param nodeType the type of node currently connected to (this.appContextService.connectionManager.activeConnection.type)
* @return string
*/
private static getFormattedNodeId;
/**
* Gets the level of current logging.
*/
get consoleLogLevel(): LogLevel;
/**
* Gets the session Id of shell.
*/
private get sessionId();
/**
* Gets the name of current shell or module.
*/
private get nameOfModule();
/**
* Initializes a new instance of the Logging class.
*/
constructor();
/**
* Gets the current logging instance.
*/
static get current(): Logging;
/**
* Flush the regular log set, immediately submitting the logs to the gateway
*/
static flushLogs(): void;
/**
* Flush the telemetry log set, immediately submitting the logs to the gateway
*/
static flushTelemetry(): void;
/**
* Register Rpc object to logging instance.
*
* @param rpc the rpc instance.
*/
registerRpc(rpc: Rpc, gateway: GatewayConnection): void;
/**
* Dispose the set of rpc forwarding pipes.
*/
dispose(): void;
/**
* Log a record.
*
* @param record the log record.
* @return Promise<any> the promise object.
*/
private logInternal;
/**
* Log a telemerty record.
*
* @param record the telemetry record.
* @return Promise<any> the promise object.
*/
private telemetryInternal;
/**
* Dispose the set.
*
* @param set the logger set.
*/
private disposeSet;
/**
* Log to the gateway.
*
* @param set the logger set.
* @param data the record data.
*/
private logGateway;
/**
* Flush a log set, immediately submitting the logs to the gateway
*/
private flush;
/**
* Submit records to the gateway.
*/
private submitRecords;
}