@microsoft/sp-diagnostics 1.22.0-beta.2 → 1.22.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/78359e4b-07c2-43c6-8d0b-d060b4d577e8.manifest.json +3 -3
- package/dist/{sp-diagnostics_none_a5c0c2a17bce8b457f0d.js → sp-diagnostics_none_f723633aa801623e45a1.js} +1 -1
- package/lib/Api/Engagement/EngagementLogger.d.ts +75 -0
- package/lib/Api/Engagement/EngagementLogger.d.ts.map +1 -0
- package/lib/Api/Engagement/EngagementLogger.js +143 -0
- package/lib/Api/Engagement/IEngagementHandler.d.ts +87 -0
- package/lib/Api/Engagement/IEngagementHandler.d.ts.map +1 -0
- package/lib/Api/Engagement/IEngagementHandler.js +2 -0
- package/lib/Api/ExecutionQueue.d.ts +55 -0
- package/lib/Api/ExecutionQueue.d.ts.map +1 -0
- package/lib/Api/ExecutionQueue.js +133 -0
- package/lib/Api/ILogData.d.ts +36 -0
- package/lib/Api/ILogData.d.ts.map +1 -0
- package/lib/Api/ILogData.js +3 -0
- package/lib/Api/ILogEntry.d.ts +29 -0
- package/lib/Api/ILogEntry.d.ts.map +1 -0
- package/lib/Api/ILogEntry.js +2 -0
- package/lib/Api/ILogErrorData.d.ts +21 -0
- package/lib/Api/ILogErrorData.d.ts.map +1 -0
- package/lib/Api/ILogErrorData.js +3 -0
- package/lib/Api/ILogSource.d.ts +10 -0
- package/lib/Api/ILogSource.d.ts.map +1 -0
- package/lib/Api/ILogSource.js +3 -0
- package/lib/Api/ILogVerboseData.d.ts +12 -0
- package/lib/Api/ILogVerboseData.d.ts.map +1 -0
- package/lib/Api/ILogVerboseData.js +3 -0
- package/lib/Api/Log/LogHandler.d.ts +12 -0
- package/lib/Api/Log/LogHandler.d.ts.map +1 -0
- package/lib/Api/Log/LogHandler.js +41 -0
- package/lib/Api/LogEntry.d.ts +29 -0
- package/lib/Api/LogEntry.d.ts.map +1 -0
- package/lib/Api/LogEntry.js +51 -0
- package/lib/Api/LogFeature.d.ts +7 -0
- package/lib/Api/LogFeature.d.ts.map +1 -0
- package/lib/Api/LogFeature.js +11 -0
- package/lib/Api/LogLevel.d.ts +23 -0
- package/lib/Api/LogLevel.d.ts.map +1 -0
- package/lib/Api/LogLevel.js +24 -0
- package/lib/Api/LogManager/CircularBuffer.d.ts +36 -0
- package/lib/Api/LogManager/CircularBuffer.d.ts.map +1 -0
- package/lib/Api/LogManager/CircularBuffer.js +98 -0
- package/lib/Api/LogManager/LogManager.d.ts +47 -0
- package/lib/Api/LogManager/LogManager.d.ts.map +1 -0
- package/lib/Api/LogManager/LogManager.js +121 -0
- package/lib/Api/LogSource.d.ts +24 -0
- package/lib/Api/LogSource.d.ts.map +1 -0
- package/lib/Api/LogSource.js +40 -0
- package/lib/Api/LogType.d.ts +21 -0
- package/lib/Api/LogType.d.ts.map +1 -0
- package/lib/Api/LogType.js +23 -0
- package/lib/Api/Qos/AutoAlertableQosMonitor.d.ts +72 -0
- package/lib/Api/Qos/AutoAlertableQosMonitor.d.ts.map +1 -0
- package/lib/Api/Qos/AutoAlertableQosMonitor.js +93 -0
- package/lib/Api/Qos/CustomerPromiseInterfaces/ICustomerPromiseErrorDetails.d.ts +39 -0
- package/lib/Api/Qos/CustomerPromiseInterfaces/ICustomerPromiseErrorDetails.d.ts.map +1 -0
- package/lib/Api/Qos/CustomerPromiseInterfaces/ICustomerPromiseErrorDetails.js +2 -0
- package/lib/Api/Qos/CustomerPromiseInterfaces/IExtraDataForCustomerPromise.d.ts +12 -0
- package/lib/Api/Qos/CustomerPromiseInterfaces/IExtraDataForCustomerPromise.d.ts.map +1 -0
- package/lib/Api/Qos/CustomerPromiseInterfaces/IExtraDataForCustomerPromise.js +2 -0
- package/lib/Api/Qos/IQos.d.ts +17 -0
- package/lib/Api/Qos/IQos.d.ts.map +1 -0
- package/lib/Api/Qos/IQos.js +2 -0
- package/lib/Api/Qos/IQosEndEvent.d.ts +13 -0
- package/lib/Api/Qos/IQosEndEvent.d.ts.map +1 -0
- package/lib/Api/Qos/IQosEndEvent.js +2 -0
- package/lib/Api/Qos/IQosExtraData.d.ts +50 -0
- package/lib/Api/Qos/IQosExtraData.d.ts.map +1 -0
- package/lib/Api/Qos/IQosExtraData.js +2 -0
- package/lib/Api/Qos/IQosStartEvent.d.ts +8 -0
- package/lib/Api/Qos/IQosStartEvent.d.ts.map +1 -0
- package/lib/Api/Qos/IQosStartEvent.js +2 -0
- package/lib/Api/Qos/QosLogger.d.ts +27 -0
- package/lib/Api/Qos/QosLogger.d.ts.map +1 -0
- package/lib/Api/Qos/QosLogger.js +74 -0
- package/lib/Api/Qos/QosMonitor.d.ts +74 -0
- package/lib/Api/Qos/QosMonitor.d.ts.map +1 -0
- package/lib/Api/Qos/QosMonitor.js +304 -0
- package/lib/Api/Qos/QosMonitorShareFailureWithCP.d.ts +50 -0
- package/lib/Api/Qos/QosMonitorShareFailureWithCP.d.ts.map +1 -0
- package/lib/Api/Qos/QosMonitorShareFailureWithCP.js +114 -0
- package/lib/Api/Qos/QosResultType.d.ts +15 -0
- package/lib/Api/Qos/QosResultType.d.ts.map +1 -0
- package/lib/Api/Qos/QosResultType.js +11 -0
- package/lib/Api/Trace/DefaultTraceHandler.d.ts +15 -0
- package/lib/Api/Trace/DefaultTraceHandler.d.ts.map +1 -0
- package/lib/Api/Trace/DefaultTraceHandler.js +30 -0
- package/lib/Api/Trace/ITraceHandler.d.ts +29 -0
- package/lib/Api/Trace/ITraceHandler.d.ts.map +1 -0
- package/lib/Api/Trace/ITraceHandler.js +2 -0
- package/lib/Api/Trace/ITraceLogger.d.ts +13 -0
- package/lib/Api/Trace/ITraceLogger.d.ts.map +1 -0
- package/lib/Api/Trace/ITraceLogger.js +2 -0
- package/lib/Api/Trace/LogEvent.d.ts +49 -0
- package/lib/Api/Trace/LogEvent.d.ts.map +1 -0
- package/lib/Api/Trace/LogEvent.js +147 -0
- package/lib/Api/Trace/TraceLogger.d.ts +102 -0
- package/lib/Api/Trace/TraceLogger.d.ts.map +1 -0
- package/lib/Api/Trace/TraceLogger.js +197 -0
- package/lib/Diagnostics.d.ts +47 -0
- package/lib/Diagnostics.d.ts.map +1 -0
- package/lib/Diagnostics.js +82 -0
- package/lib/DiagnosticsSettingsManager.d.ts +19 -0
- package/lib/DiagnosticsSettingsManager.d.ts.map +1 -0
- package/lib/DiagnosticsSettingsManager.js +62 -0
- package/lib/IDiagnosticsSettings.d.ts +87 -0
- package/lib/IDiagnosticsSettings.d.ts.map +1 -0
- package/lib/IDiagnosticsSettings.js +2 -0
- package/lib/common/Killswitches.d.ts +3 -0
- package/lib/common/Killswitches.d.ts.map +1 -0
- package/lib/common/Killswitches.js +14 -0
- package/lib/extraData/DisplayApp.d.ts +6 -0
- package/lib/extraData/DisplayApp.d.ts.map +1 -0
- package/lib/extraData/DisplayApp.js +6 -0
- package/lib/extraData/IDiagnosticContextInfo.d.ts +18 -0
- package/lib/extraData/IDiagnosticContextInfo.d.ts.map +1 -0
- package/lib/extraData/IDiagnosticContextInfo.js +2 -0
- package/lib/extraData/IPageExtraData.d.ts +16 -0
- package/lib/extraData/IPageExtraData.d.ts.map +1 -0
- package/lib/extraData/IPageExtraData.js +2 -0
- package/lib/extraData/PageType.d.ts +13 -0
- package/lib/extraData/PageType.d.ts.map +1 -0
- package/lib/extraData/PageType.js +16 -0
- package/lib/extraData/PromotedState.d.ts +16 -0
- package/lib/extraData/PromotedState.d.ts.map +1 -0
- package/lib/extraData/PromotedState.js +17 -0
- package/lib/extraData/WebTemplateId.d.ts +8 -0
- package/lib/extraData/WebTemplateId.d.ts.map +1 -0
- package/lib/extraData/WebTemplateId.js +10 -0
- package/lib/extraData/setPageExtraData.d.ts +5 -0
- package/lib/extraData/setPageExtraData.d.ts.map +1 -0
- package/lib/extraData/setPageExtraData.js +66 -0
- package/lib/index.d.ts +42 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +27 -0
- package/lib/sp-diagnostics.manifest.json +8 -0
- package/lib-commonjs/common/Killswitches.js +8 -1
- package/lib-commonjs/extraData/setPageExtraData.js +4 -0
- package/package.json +6 -6
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QosResultType.d.ts","sourceRoot":"","sources":["../../../src/Api/Qos/QosResultType.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,eAAO,MAAM,aAAa;;;;CAIhB,CAAC;AAEX;;;GAGG;AAEH,MAAM,MAAM,aAAa,GAAG,OAAO,aAAa,CAAC,MAAM,OAAO,aAAa,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ITraceHandler, ITraceLogEvent, IVerboseTraceLogEvent } from './ITraceHandler';
|
|
2
|
+
/**
|
|
3
|
+
* Default implementation for the Trace logger class.
|
|
4
|
+
*/
|
|
5
|
+
export default class DefaultTraceHandler implements ITraceHandler {
|
|
6
|
+
/**
|
|
7
|
+
* Default implementation for log function.
|
|
8
|
+
*/
|
|
9
|
+
log(traceLogEvent: ITraceLogEvent): void;
|
|
10
|
+
/**
|
|
11
|
+
* Default implementation for verbose function.
|
|
12
|
+
*/
|
|
13
|
+
verbose(verboseTraceEvent: IVerboseTraceLogEvent): void;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=DefaultTraceHandler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DefaultTraceHandler.d.ts","sourceRoot":"","sources":["../../../src/Api/Trace/DefaultTraceHandler.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAE5F;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,mBAAoB,YAAW,aAAa;IAC/D;;OAEG;IACI,GAAG,CAAC,aAAa,EAAE,cAAc,GAAG,IAAI;IAW/C;;OAEG;IACI,OAAO,CAAC,iBAAiB,EAAE,qBAAqB,GAAG,IAAI;CAM/D"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default implementation for the Trace logger class.
|
|
3
|
+
*/
|
|
4
|
+
var DefaultTraceHandler = /** @class */ (function () {
|
|
5
|
+
function DefaultTraceHandler() {
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Default implementation for log function.
|
|
9
|
+
*/
|
|
10
|
+
DefaultTraceHandler.prototype.log = function (traceLogEvent) {
|
|
11
|
+
if (!DEPRECATED_UNIT_TEST) {
|
|
12
|
+
// eslint-disable-next-line no-console
|
|
13
|
+
console.log("Error: ".concat(traceLogEvent.data, ", ") +
|
|
14
|
+
"Event Name: ".concat(traceLogEvent.eventName, ", ") +
|
|
15
|
+
"Result Code: ".concat(traceLogEvent.resultCode));
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Default implementation for verbose function.
|
|
20
|
+
*/
|
|
21
|
+
DefaultTraceHandler.prototype.verbose = function (verboseTraceEvent) {
|
|
22
|
+
if (!DEPRECATED_UNIT_TEST) {
|
|
23
|
+
// eslint-disable-next-line no-console
|
|
24
|
+
console.log("Error: ".concat(verboseTraceEvent.data, ", Event Name: ").concat(verboseTraceEvent.eventName));
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
return DefaultTraceHandler;
|
|
28
|
+
}());
|
|
29
|
+
export default DefaultTraceHandler;
|
|
30
|
+
//# sourceMappingURL=DefaultTraceHandler.js.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trace logger log data interface
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
5
|
+
export interface ITraceHandler {
|
|
6
|
+
/** Trace logging operation **/
|
|
7
|
+
log(traceEvent: ITraceLogEvent): void;
|
|
8
|
+
/** Verbose trace logging operation **/
|
|
9
|
+
verbose(traceVerboseEvent: IVerboseTraceLogEvent): void;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* IVerboseTraceLogEvent log data interface
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
export interface IVerboseTraceLogEvent {
|
|
16
|
+
/** Data for the Trace Log **/
|
|
17
|
+
data: string | Error;
|
|
18
|
+
/** Event Name for the Trace Log **/
|
|
19
|
+
eventName: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* ITraceLogEvent log data interface
|
|
23
|
+
* @internal
|
|
24
|
+
*/
|
|
25
|
+
export interface ITraceLogEvent extends IVerboseTraceLogEvent {
|
|
26
|
+
/** Result Code for the Trace Log **/
|
|
27
|
+
resultCode?: string;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=ITraceHandler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ITraceHandler.d.ts","sourceRoot":"","sources":["../../../src/Api/Trace/ITraceHandler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,+BAA+B;IAC/B,GAAG,CAAC,UAAU,EAAE,cAAc,GAAG,IAAI,CAAC;IAEtC,uCAAuC;IACvC,OAAO,CAAC,iBAAiB,EAAE,qBAAqB,GAAG,IAAI,CAAC;CACzD;AAED;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,8BAA8B;IAC9B,IAAI,EAAE,MAAM,GAAG,KAAK,CAAC;IAErB,oCAAoC;IACpC,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,MAAM,WAAW,cAAe,SAAQ,qBAAqB;IAC3D,qCAAqC;IACrC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type ILogEntry from '../ILogEntry';
|
|
2
|
+
import type ILogSource from '../ILogSource';
|
|
3
|
+
/**
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
interface ITraceLogger {
|
|
7
|
+
logError(source: ILogSource, error: Error, eventName?: string, resultCode?: string): void;
|
|
8
|
+
logVerbose(source: ILogSource, message: string, eventName?: string): void;
|
|
9
|
+
logErrorWithLogEntry(source: ILogSource, logEntry: ILogEntry, eventName?: string, resultCode?: string): void;
|
|
10
|
+
logVerboseWithLogEntry(source: ILogSource, logEntry: ILogEntry, eventName?: string): void;
|
|
11
|
+
}
|
|
12
|
+
export default ITraceLogger;
|
|
13
|
+
//# sourceMappingURL=ITraceLogger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ITraceLogger.d.ts","sourceRoot":"","sources":["../../../src/Api/Trace/ITraceLogger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,cAAc,CAAC;AAC1C,OAAO,KAAK,UAAU,MAAM,eAAe,CAAC;AAE5C;;GAEG;AACH,UAAU,YAAY;IACpB,QAAQ,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1F,UAAU,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1E,oBAAoB,CAClB,MAAM,EAAE,UAAU,EAClB,QAAQ,EAAE,SAAS,EACnB,SAAS,CAAC,EAAE,MAAM,EAClB,UAAU,CAAC,EAAE,MAAM,GAClB,IAAI,CAAC;IACR,sBAAsB,CAAC,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3F;AAED,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { ServiceScope } from '@microsoft/sp-core-library';
|
|
2
|
+
import { type default as LogSource } from '../LogSource';
|
|
3
|
+
import type { LogLevel } from '../LogLevel';
|
|
4
|
+
import LogManager from '../LogManager/LogManager';
|
|
5
|
+
/**
|
|
6
|
+
* An object that represents one log event.
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export default class LogEvent {
|
|
10
|
+
/**
|
|
11
|
+
* Allows process log events.
|
|
12
|
+
*/
|
|
13
|
+
static logManager: LogManager<LogEvent>;
|
|
14
|
+
private _timestamp;
|
|
15
|
+
private _scope;
|
|
16
|
+
private _source;
|
|
17
|
+
private _message;
|
|
18
|
+
private _error;
|
|
19
|
+
private _level;
|
|
20
|
+
private _prefix;
|
|
21
|
+
/**
|
|
22
|
+
* Use this method to log an event.
|
|
23
|
+
*
|
|
24
|
+
* @param source - source of the log event, e.g. class name of the source file
|
|
25
|
+
* @param data - data of the log event
|
|
26
|
+
* @param level - level of the log event
|
|
27
|
+
* @param serviceScope - scope of the log event, e.g. component/web part
|
|
28
|
+
*/
|
|
29
|
+
static log(source: string, data: string | Error, level: LogLevel, serviceScope?: ServiceScope): LogEvent;
|
|
30
|
+
/**
|
|
31
|
+
* Do not call this constructor directly. Use LogEvent.log instead.
|
|
32
|
+
*/
|
|
33
|
+
constructor(source: string, data: string | Error, level: LogLevel, serviceScope?: ServiceScope);
|
|
34
|
+
toString(): string;
|
|
35
|
+
get timestamp(): number;
|
|
36
|
+
get level(): LogLevel;
|
|
37
|
+
get prefix(): string;
|
|
38
|
+
get scope(): LogSource | undefined;
|
|
39
|
+
get source(): string;
|
|
40
|
+
get message(): string | undefined;
|
|
41
|
+
get error(): Error | undefined;
|
|
42
|
+
private get _maxSourceLength();
|
|
43
|
+
private get _maxMessageLength();
|
|
44
|
+
private _validate;
|
|
45
|
+
private _setData;
|
|
46
|
+
private _getPrefix;
|
|
47
|
+
private _getScope;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=LogEvent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LogEvent.d.ts","sourceRoot":"","sources":["../../../src/Api/Trace/LogEvent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,KAAK,OAAO,IAAI,SAAS,EAAuB,MAAM,cAAc,CAAC;AAC9E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,UAAU,MAAM,0BAA0B,CAAC;AAElD;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,QAAQ;IAC3B;;OAEG;IACH,OAAc,UAAU,EAAE,UAAU,CAAC,QAAQ,CAAC,CAA8B;IAE5E,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,MAAM,CAAwB;IACtC,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,QAAQ,CAAqB;IACrC,OAAO,CAAC,MAAM,CAAoB;IAClC,OAAO,CAAC,MAAM,CAAW;IACzB,OAAO,CAAC,OAAO,CAAS;IAExB;;;;;;;OAOG;WACW,GAAG,CACf,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,GAAG,KAAK,EACpB,KAAK,EAAE,QAAQ,EACf,YAAY,CAAC,EAAE,YAAY,GAC1B,QAAQ;IAMX;;OAEG;gBACgB,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,CAAC,EAAE,YAAY;IAU9F,QAAQ,IAAI,MAAM;IAWzB,IAAW,SAAS,IAAI,MAAM,CAE7B;IAED,IAAW,KAAK,IAAI,QAAQ,CAE3B;IAED,IAAW,MAAM,IAAI,MAAM,CAE1B;IAED,IAAW,KAAK,IAAI,SAAS,GAAG,SAAS,CAExC;IAED,IAAW,MAAM,IAAI,MAAM,CAE1B;IAED,IAAW,OAAO,IAAI,MAAM,GAAG,SAAS,CAEvC;IAED,IAAW,KAAK,IAAI,KAAK,GAAG,SAAS,CAEpC;IAED,OAAO,KAAK,gBAAgB,GAE3B;IAED,OAAO,KAAK,iBAAiB,GAE5B;IAED,OAAO,CAAC,SAAS;IASjB,OAAO,CAAC,QAAQ;IAQhB,OAAO,CAAC,UAAU;IAQlB,OAAO,CAAC,SAAS;CAUlB"}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { logSourceServiceKey } from '../LogSource';
|
|
2
|
+
import LogManager from '../LogManager/LogManager';
|
|
3
|
+
/**
|
|
4
|
+
* An object that represents one log event.
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
var LogEvent = /** @class */ (function () {
|
|
8
|
+
/**
|
|
9
|
+
* Do not call this constructor directly. Use LogEvent.log instead.
|
|
10
|
+
*/
|
|
11
|
+
function LogEvent(source, data, level, serviceScope) {
|
|
12
|
+
this._validate(source, data);
|
|
13
|
+
this._timestamp = new Date().getTime();
|
|
14
|
+
this._scope = this._getScope(serviceScope);
|
|
15
|
+
this._source = source.substr(0, this._maxSourceLength);
|
|
16
|
+
this._setData(data);
|
|
17
|
+
this._level = level;
|
|
18
|
+
this._prefix = this._getPrefix();
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Use this method to log an event.
|
|
22
|
+
*
|
|
23
|
+
* @param source - source of the log event, e.g. class name of the source file
|
|
24
|
+
* @param data - data of the log event
|
|
25
|
+
* @param level - level of the log event
|
|
26
|
+
* @param serviceScope - scope of the log event, e.g. component/web part
|
|
27
|
+
*/
|
|
28
|
+
LogEvent.log = function (source, data, level, serviceScope) {
|
|
29
|
+
var event = new LogEvent(source, data, level, serviceScope);
|
|
30
|
+
LogEvent.logManager.log(event);
|
|
31
|
+
return event;
|
|
32
|
+
};
|
|
33
|
+
LogEvent.prototype.toString = function () {
|
|
34
|
+
var timedPrefix = "[".concat(this._timestamp, "][").concat(this._prefix, "]");
|
|
35
|
+
if (this._message) {
|
|
36
|
+
return "".concat(timedPrefix, " ").concat(this._message);
|
|
37
|
+
}
|
|
38
|
+
else if (this._error) {
|
|
39
|
+
return "".concat(timedPrefix, " ").concat(this._error.toString());
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
return timedPrefix;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
Object.defineProperty(LogEvent.prototype, "timestamp", {
|
|
46
|
+
get: function () {
|
|
47
|
+
return this._timestamp;
|
|
48
|
+
},
|
|
49
|
+
enumerable: false,
|
|
50
|
+
configurable: true
|
|
51
|
+
});
|
|
52
|
+
Object.defineProperty(LogEvent.prototype, "level", {
|
|
53
|
+
get: function () {
|
|
54
|
+
return this._level;
|
|
55
|
+
},
|
|
56
|
+
enumerable: false,
|
|
57
|
+
configurable: true
|
|
58
|
+
});
|
|
59
|
+
Object.defineProperty(LogEvent.prototype, "prefix", {
|
|
60
|
+
get: function () {
|
|
61
|
+
return this._prefix;
|
|
62
|
+
},
|
|
63
|
+
enumerable: false,
|
|
64
|
+
configurable: true
|
|
65
|
+
});
|
|
66
|
+
Object.defineProperty(LogEvent.prototype, "scope", {
|
|
67
|
+
get: function () {
|
|
68
|
+
return this._scope;
|
|
69
|
+
},
|
|
70
|
+
enumerable: false,
|
|
71
|
+
configurable: true
|
|
72
|
+
});
|
|
73
|
+
Object.defineProperty(LogEvent.prototype, "source", {
|
|
74
|
+
get: function () {
|
|
75
|
+
return this._source;
|
|
76
|
+
},
|
|
77
|
+
enumerable: false,
|
|
78
|
+
configurable: true
|
|
79
|
+
});
|
|
80
|
+
Object.defineProperty(LogEvent.prototype, "message", {
|
|
81
|
+
get: function () {
|
|
82
|
+
return this._message;
|
|
83
|
+
},
|
|
84
|
+
enumerable: false,
|
|
85
|
+
configurable: true
|
|
86
|
+
});
|
|
87
|
+
Object.defineProperty(LogEvent.prototype, "error", {
|
|
88
|
+
get: function () {
|
|
89
|
+
return this._error;
|
|
90
|
+
},
|
|
91
|
+
enumerable: false,
|
|
92
|
+
configurable: true
|
|
93
|
+
});
|
|
94
|
+
Object.defineProperty(LogEvent.prototype, "_maxSourceLength", {
|
|
95
|
+
get: function () {
|
|
96
|
+
return 30;
|
|
97
|
+
},
|
|
98
|
+
enumerable: false,
|
|
99
|
+
configurable: true
|
|
100
|
+
});
|
|
101
|
+
Object.defineProperty(LogEvent.prototype, "_maxMessageLength", {
|
|
102
|
+
get: function () {
|
|
103
|
+
return 150;
|
|
104
|
+
},
|
|
105
|
+
enumerable: false,
|
|
106
|
+
configurable: true
|
|
107
|
+
});
|
|
108
|
+
LogEvent.prototype._validate = function (source, data) {
|
|
109
|
+
if (!source) {
|
|
110
|
+
throw new Error('source cannot be undefined or null for Logger');
|
|
111
|
+
}
|
|
112
|
+
if (!data) {
|
|
113
|
+
throw new Error('data cannot be undefined or null');
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
LogEvent.prototype._setData = function (data) {
|
|
117
|
+
if (typeof data === 'string') {
|
|
118
|
+
this._message = data.substr(0, this._maxMessageLength);
|
|
119
|
+
}
|
|
120
|
+
else if (data instanceof Error) {
|
|
121
|
+
this._error = data;
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
LogEvent.prototype._getPrefix = function () {
|
|
125
|
+
var prefix = "".concat(this._source);
|
|
126
|
+
if (this._scope && !this._scope.isEmpty()) {
|
|
127
|
+
prefix = "".concat(this._scope.id.substr(0, this._maxSourceLength), ".").concat(prefix);
|
|
128
|
+
}
|
|
129
|
+
return "".concat(prefix);
|
|
130
|
+
};
|
|
131
|
+
LogEvent.prototype._getScope = function (serviceScope) {
|
|
132
|
+
var parentSource;
|
|
133
|
+
if (serviceScope) {
|
|
134
|
+
serviceScope.whenFinished(function () {
|
|
135
|
+
parentSource = serviceScope.consume(logSourceServiceKey);
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
return parentSource;
|
|
139
|
+
};
|
|
140
|
+
/**
|
|
141
|
+
* Allows process log events.
|
|
142
|
+
*/
|
|
143
|
+
LogEvent.logManager = new LogManager();
|
|
144
|
+
return LogEvent;
|
|
145
|
+
}());
|
|
146
|
+
export default LogEvent;
|
|
147
|
+
//# sourceMappingURL=LogEvent.js.map
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type ILogEntry from '../ILogEntry';
|
|
2
|
+
import type ILogSource from '../ILogSource';
|
|
3
|
+
import type ILogErrorData from '../ILogErrorData';
|
|
4
|
+
import type ILogVerboseData from '../ILogVerboseData';
|
|
5
|
+
import type { ITraceHandler, ITraceLogEvent, IVerboseTraceLogEvent } from './ITraceHandler';
|
|
6
|
+
import LogManager from '../LogManager/LogManager';
|
|
7
|
+
/**
|
|
8
|
+
* This is used to log traces of failed operations and debugging information.
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export default class TraceLogger {
|
|
12
|
+
/**
|
|
13
|
+
* Allows process trace log events.
|
|
14
|
+
*/
|
|
15
|
+
static _logManager: LogManager<ITraceLogEvent>;
|
|
16
|
+
/**
|
|
17
|
+
* Allows process verbose trace log events.
|
|
18
|
+
*/
|
|
19
|
+
static _verboseLogManager: LogManager<IVerboseTraceLogEvent>;
|
|
20
|
+
private static _defaultLogger;
|
|
21
|
+
private static _shouldWriteToConsole;
|
|
22
|
+
/**
|
|
23
|
+
* Init function for the passed logger object
|
|
24
|
+
*
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
static _addHandler(logger: ITraceHandler): void;
|
|
28
|
+
/**
|
|
29
|
+
* Exception logging
|
|
30
|
+
* This shoule be used whenever you want to log something that might in future help to debug failures.
|
|
31
|
+
* The error parameter is the only required one and basically will be just converted to string and
|
|
32
|
+
* logged to Debug stream (RealibilityLogs in SLAPI).
|
|
33
|
+
* It will also be uploaded to the server immediately and not wait for next batch log upload.
|
|
34
|
+
* If you don't specify second parameter:eventName
|
|
35
|
+
* the event name for all errors logged that way will be same "CaughtError" with
|
|
36
|
+
* appropriate prefix ("ModernPublish.CaughtError" etc.)
|
|
37
|
+
* These two parameters "eventName and resultCode" are there to be used from Qos.
|
|
38
|
+
* It is not encouraged to use them directly from ErrorHelper but if you do,
|
|
39
|
+
* the log will be written with custom event name of following format:
|
|
40
|
+
* <Workload>.<eventName>.<resultCode>.Failure, Workload is set in Telemetry settings.
|
|
41
|
+
**/
|
|
42
|
+
static logError(source: ILogSource, error: Error, eventName?: string, resultCode?: string): void;
|
|
43
|
+
/**
|
|
44
|
+
* Exception logging intended to replace to logError.
|
|
45
|
+
*
|
|
46
|
+
* @remarks
|
|
47
|
+
* Uses the `ILogErrorData` interface to prevent excessive undefined parameters
|
|
48
|
+
* when calling this function.
|
|
49
|
+
* This should be used whenever you want to log something that might in future help to
|
|
50
|
+
* debug failures.
|
|
51
|
+
* It will also be uploaded to the server immediately and not wait for next batch log upload.
|
|
52
|
+
*/
|
|
53
|
+
static logErrorData(data: ILogErrorData): void;
|
|
54
|
+
/**
|
|
55
|
+
* Trace logging
|
|
56
|
+
* The idea here is that verbose logs don't get uploaded to the server unless
|
|
57
|
+
* a failure is logged using ErrorHelper.log method.
|
|
58
|
+
* There is a circular buffer that holds last 50 verbose logs from all scenarios and
|
|
59
|
+
* it is only flushed and uploaded in case a failure is logged.
|
|
60
|
+
* That way whenever you get a failure event with message you also have all supportive verbose messages
|
|
61
|
+
* you logged throughout your scenario execution (or other scenarios).
|
|
62
|
+
* And hopefully that would help you get to the bottom of what exactly went wrong.
|
|
63
|
+
* If no failure happens and your scenario succeeds, verbose logs will be just left in the buffer
|
|
64
|
+
* and most likely overriden by next scenario that logs something verbose.
|
|
65
|
+
**/
|
|
66
|
+
static logVerbose(source: ILogSource, message: string, eventName?: string): void;
|
|
67
|
+
/**
|
|
68
|
+
* Verbose logging intended to replace to logVerbose.
|
|
69
|
+
* The idea here is that verbose logs don't get uploaded to the server unless
|
|
70
|
+
* a failure is logged using ErrorHelper.log method.
|
|
71
|
+
* There is a circular buffer that holds last 50 verbose logs from all scenarios and
|
|
72
|
+
* it is only flushed and uploaded in case a failure is logged.
|
|
73
|
+
* That way whenever you get a failure event with message you also have all supportive verbose messages
|
|
74
|
+
* you logged throughout your scenario execution (or other scenarios).
|
|
75
|
+
* And hopefully that would help you get to the bottom of what exactly went wrong.
|
|
76
|
+
* If no failure happens and your scenario succeeds, verbose logs will be just left in the buffer
|
|
77
|
+
* and most likely overridden by next scenario that logs something verbose.
|
|
78
|
+
*/
|
|
79
|
+
static logVerboseData(data: ILogVerboseData): void;
|
|
80
|
+
/**
|
|
81
|
+
* Exception logging With LogEntry
|
|
82
|
+
* error message should be packed into logProperties
|
|
83
|
+
* LogType should be LogType.Error and LogProperties should have `{error:errorMessage}`
|
|
84
|
+
* Do NOT add PII data!
|
|
85
|
+
**/
|
|
86
|
+
static logErrorWithLogEntry(source: ILogSource, logEntry: ILogEntry, eventName?: string, resultCode?: string): void;
|
|
87
|
+
/**
|
|
88
|
+
* Indicates if the log entries should be output to the console.
|
|
89
|
+
* This flag is set to true by default.
|
|
90
|
+
*/
|
|
91
|
+
static get shouldWriteToConsole(): boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Toggles console output functionality.
|
|
94
|
+
* Property can be chaged by remote caller.
|
|
95
|
+
*/
|
|
96
|
+
static set shouldWriteToConsole(shouldWrite: boolean);
|
|
97
|
+
static logVerboseWithLogEntry(source: ILogSource, logEntry: ILogEntry, eventName?: string): void;
|
|
98
|
+
private static _log;
|
|
99
|
+
private static _addEventPrefix;
|
|
100
|
+
private static _writeToConsole;
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=TraceLogger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TraceLogger.d.ts","sourceRoot":"","sources":["../../../src/Api/Trace/TraceLogger.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,SAAS,MAAM,cAAc,CAAC;AAC1C,OAAO,KAAK,UAAU,MAAM,eAAe,CAAC;AAG5C,OAAO,KAAK,aAAa,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,eAAe,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAE5F,OAAO,UAAU,MAAM,0BAA0B,CAAC;AAElD;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,WAAW;IAC9B;;OAEG;IACH,OAAc,WAAW,EAAE,UAAU,CAAC,cAAc,CAAC,CAAoC;IAEzF;;OAEG;IACH,OAAc,kBAAkB,EAAE,UAAU,CAAC,qBAAqB,CAAC,CACzB;IAE1C,OAAO,CAAC,MAAM,CAAC,cAAc,CAA4C;IACzE,OAAO,CAAC,MAAM,CAAC,qBAAqB,CAAkB;IAEtD;;;;OAIG;WACW,WAAW,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI;IAOtD;;;;;;;;;;;;;QAaI;WACU,QAAQ,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI;IAKvG;;;;;;;;;OASG;WACW,YAAY,CAAC,IAAI,EAAE,aAAa,GAAG,IAAI;IAMrD;;;;;;;;;;;QAWI;WACU,UAAU,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI;IAKvF;;;;;;;;;;;OAWG;WACW,cAAc,CAAC,IAAI,EAAE,eAAe,GAAG,IAAI;IAKzD;;;;;QAKI;WACU,oBAAoB,CAChC,MAAM,EAAE,UAAU,EAClB,QAAQ,EAAE,SAAS,EACnB,SAAS,CAAC,EAAE,MAAM,EAClB,UAAU,CAAC,EAAE,MAAM,GAClB,IAAI;IAMP;;;OAGG;IACH,WAAkB,oBAAoB,IAAI,OAAO,CAEhD;IAED;;;OAGG;IACH,WAAkB,oBAAoB,CAAC,WAAW,EAAE,OAAO,EAS1D;WASa,sBAAsB,CAAC,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI;IAKvG,OAAO,CAAC,MAAM,CAAC,IAAI;IA2BnB,OAAO,CAAC,MAAM,CAAC,eAAe;IAY9B,OAAO,CAAC,MAAM,CAAC,eAAe;CAgB/B"}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { Validate } from '@microsoft/sp-core-library';
|
|
2
|
+
import LogEvent from './LogEvent';
|
|
3
|
+
import { LogLevel } from '../LogLevel';
|
|
4
|
+
import DefaultTraceHandler from './DefaultTraceHandler';
|
|
5
|
+
import LogManager from '../LogManager/LogManager';
|
|
6
|
+
/**
|
|
7
|
+
* This is used to log traces of failed operations and debugging information.
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
var TraceLogger = /** @class */ (function () {
|
|
11
|
+
function TraceLogger() {
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Init function for the passed logger object
|
|
15
|
+
*
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
TraceLogger._addHandler = function (logger) {
|
|
19
|
+
TraceLogger._logManager.addHandler(logger.log);
|
|
20
|
+
TraceLogger._logManager.processAll(logger.log);
|
|
21
|
+
TraceLogger._verboseLogManager.addHandler(logger.verbose);
|
|
22
|
+
TraceLogger._verboseLogManager.processAll(logger.verbose);
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Exception logging
|
|
26
|
+
* This shoule be used whenever you want to log something that might in future help to debug failures.
|
|
27
|
+
* The error parameter is the only required one and basically will be just converted to string and
|
|
28
|
+
* logged to Debug stream (RealibilityLogs in SLAPI).
|
|
29
|
+
* It will also be uploaded to the server immediately and not wait for next batch log upload.
|
|
30
|
+
* If you don't specify second parameter:eventName
|
|
31
|
+
* the event name for all errors logged that way will be same "CaughtError" with
|
|
32
|
+
* appropriate prefix ("ModernPublish.CaughtError" etc.)
|
|
33
|
+
* These two parameters "eventName and resultCode" are there to be used from Qos.
|
|
34
|
+
* It is not encouraged to use them directly from ErrorHelper but if you do,
|
|
35
|
+
* the log will be written with custom event name of following format:
|
|
36
|
+
* <Workload>.<eventName>.<resultCode>.Failure, Workload is set in Telemetry settings.
|
|
37
|
+
**/
|
|
38
|
+
TraceLogger.logError = function (source, error, eventName, resultCode) {
|
|
39
|
+
Validate.isNotNullOrUndefined(error, 'error');
|
|
40
|
+
this._log(source, error, eventName, true, resultCode);
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Exception logging intended to replace to logError.
|
|
44
|
+
*
|
|
45
|
+
* @remarks
|
|
46
|
+
* Uses the `ILogErrorData` interface to prevent excessive undefined parameters
|
|
47
|
+
* when calling this function.
|
|
48
|
+
* This should be used whenever you want to log something that might in future help to
|
|
49
|
+
* debug failures.
|
|
50
|
+
* It will also be uploaded to the server immediately and not wait for next batch log upload.
|
|
51
|
+
*/
|
|
52
|
+
TraceLogger.logErrorData = function (data) {
|
|
53
|
+
Validate.isNotNullOrUndefined(data.error, 'error');
|
|
54
|
+
var errorInfo = data.logEntry ? data.logEntry.toString() : data.error;
|
|
55
|
+
this._log(data.source, errorInfo, data.eventName, true, data.resultCode, data.serviceScope);
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Trace logging
|
|
59
|
+
* The idea here is that verbose logs don't get uploaded to the server unless
|
|
60
|
+
* a failure is logged using ErrorHelper.log method.
|
|
61
|
+
* There is a circular buffer that holds last 50 verbose logs from all scenarios and
|
|
62
|
+
* it is only flushed and uploaded in case a failure is logged.
|
|
63
|
+
* That way whenever you get a failure event with message you also have all supportive verbose messages
|
|
64
|
+
* you logged throughout your scenario execution (or other scenarios).
|
|
65
|
+
* And hopefully that would help you get to the bottom of what exactly went wrong.
|
|
66
|
+
* If no failure happens and your scenario succeeds, verbose logs will be just left in the buffer
|
|
67
|
+
* and most likely overriden by next scenario that logs something verbose.
|
|
68
|
+
**/
|
|
69
|
+
TraceLogger.logVerbose = function (source, message, eventName) {
|
|
70
|
+
Validate.isNonemptyString(message, 'message');
|
|
71
|
+
this._log(source, message, eventName, false, undefined);
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Verbose logging intended to replace to logVerbose.
|
|
75
|
+
* The idea here is that verbose logs don't get uploaded to the server unless
|
|
76
|
+
* a failure is logged using ErrorHelper.log method.
|
|
77
|
+
* There is a circular buffer that holds last 50 verbose logs from all scenarios and
|
|
78
|
+
* it is only flushed and uploaded in case a failure is logged.
|
|
79
|
+
* That way whenever you get a failure event with message you also have all supportive verbose messages
|
|
80
|
+
* you logged throughout your scenario execution (or other scenarios).
|
|
81
|
+
* And hopefully that would help you get to the bottom of what exactly went wrong.
|
|
82
|
+
* If no failure happens and your scenario succeeds, verbose logs will be just left in the buffer
|
|
83
|
+
* and most likely overridden by next scenario that logs something verbose.
|
|
84
|
+
*/
|
|
85
|
+
TraceLogger.logVerboseData = function (data) {
|
|
86
|
+
var message = data.logEntry ? data.logEntry.toString() : data.message;
|
|
87
|
+
this._log(data.source, message, data.eventName, false, undefined, data.serviceScope);
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Exception logging With LogEntry
|
|
91
|
+
* error message should be packed into logProperties
|
|
92
|
+
* LogType should be LogType.Error and LogProperties should have `{error:errorMessage}`
|
|
93
|
+
* Do NOT add PII data!
|
|
94
|
+
**/
|
|
95
|
+
TraceLogger.logErrorWithLogEntry = function (source, logEntry, eventName, resultCode) {
|
|
96
|
+
Validate.isNotNullOrUndefined(source, 'source');
|
|
97
|
+
Validate.isNotNullOrUndefined(logEntry, 'logEntry');
|
|
98
|
+
this._log(source, logEntry.toString(), eventName, true, resultCode);
|
|
99
|
+
};
|
|
100
|
+
Object.defineProperty(TraceLogger, "shouldWriteToConsole", {
|
|
101
|
+
/**
|
|
102
|
+
* Indicates if the log entries should be output to the console.
|
|
103
|
+
* This flag is set to true by default.
|
|
104
|
+
*/
|
|
105
|
+
get: function () {
|
|
106
|
+
return TraceLogger._shouldWriteToConsole;
|
|
107
|
+
},
|
|
108
|
+
/**
|
|
109
|
+
* Toggles console output functionality.
|
|
110
|
+
* Property can be chaged by remote caller.
|
|
111
|
+
*/
|
|
112
|
+
set: function (shouldWrite) {
|
|
113
|
+
if (TraceLogger._shouldWriteToConsole && !shouldWrite) {
|
|
114
|
+
TraceLogger._logManager.removeHandler(TraceLogger._defaultLogger.log);
|
|
115
|
+
TraceLogger._verboseLogManager.removeHandler(TraceLogger._defaultLogger.verbose);
|
|
116
|
+
}
|
|
117
|
+
else if (!TraceLogger._shouldWriteToConsole && shouldWrite) {
|
|
118
|
+
TraceLogger._logManager.addHandler(TraceLogger._defaultLogger.log);
|
|
119
|
+
TraceLogger._verboseLogManager.addHandler(TraceLogger._defaultLogger.verbose);
|
|
120
|
+
}
|
|
121
|
+
TraceLogger._shouldWriteToConsole = shouldWrite;
|
|
122
|
+
},
|
|
123
|
+
enumerable: false,
|
|
124
|
+
configurable: true
|
|
125
|
+
});
|
|
126
|
+
/*
|
|
127
|
+
* Trace logging with `LogEntry`
|
|
128
|
+
* The same with above other than wrapped log into `logEntry`
|
|
129
|
+
* Trace message should be packed into `logProperties`
|
|
130
|
+
* `LogType` should be `LogType.Trace` and LogProperties should have something like `{errors:errorMessage}`
|
|
131
|
+
* Do NOT add PII data!
|
|
132
|
+
**/
|
|
133
|
+
TraceLogger.logVerboseWithLogEntry = function (source, logEntry, eventName) {
|
|
134
|
+
Validate.isNotNullOrUndefined(logEntry, 'LogEntry');
|
|
135
|
+
this._log(source, logEntry.toString(), eventName, false, undefined);
|
|
136
|
+
};
|
|
137
|
+
TraceLogger._log = function (source, data, eventName, isError, resultCode, serviceScope) {
|
|
138
|
+
var enhancedEventName = this._addEventPrefix(source, eventName);
|
|
139
|
+
var logEvent;
|
|
140
|
+
if (isError) {
|
|
141
|
+
logEvent = LogEvent.log(enhancedEventName, data, LogLevel.Error, serviceScope);
|
|
142
|
+
TraceLogger._logManager.log({ data: data, eventName: logEvent.prefix, resultCode: resultCode });
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
logEvent = LogEvent.log(enhancedEventName, data.toString(), LogLevel.Verbose, serviceScope);
|
|
146
|
+
TraceLogger._verboseLogManager.log({ data: data, eventName: logEvent.prefix });
|
|
147
|
+
}
|
|
148
|
+
if (TraceLogger.shouldWriteToConsole || (DEBUG && !DEPRECATED_UNIT_TEST)) {
|
|
149
|
+
this._writeToConsole(logEvent, isError, resultCode);
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
/*
|
|
153
|
+
* EventName is:
|
|
154
|
+
* sourceId.eventName or sourceId if eventName is not provided.
|
|
155
|
+
*/
|
|
156
|
+
TraceLogger._addEventPrefix = function (source, eventName) {
|
|
157
|
+
if (!eventName) {
|
|
158
|
+
return source.id;
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
return "".concat(source.id, ".").concat(eventName);
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
/*
|
|
165
|
+
* The log message in console is:
|
|
166
|
+
* `[eventName]: data`.
|
|
167
|
+
*/
|
|
168
|
+
TraceLogger._writeToConsole = function (logEvent, isError, resultCode) {
|
|
169
|
+
// @todo (SPPPLAT VSO#250083): This date should be a part of the logEvent.
|
|
170
|
+
var errorString = logEvent.toString();
|
|
171
|
+
if (resultCode) {
|
|
172
|
+
errorString += ". resultCode: ".concat(resultCode);
|
|
173
|
+
}
|
|
174
|
+
// Task 191596: only write to console when a condition is satisfied (e.g., a query parameter provided).
|
|
175
|
+
if (isError) {
|
|
176
|
+
// eslint-disable-next-line no-console
|
|
177
|
+
console.error(errorString);
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
// eslint-disable-next-line no-console
|
|
181
|
+
console.log(errorString);
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
/**
|
|
185
|
+
* Allows process trace log events.
|
|
186
|
+
*/
|
|
187
|
+
TraceLogger._logManager = new LogManager();
|
|
188
|
+
/**
|
|
189
|
+
* Allows process verbose trace log events.
|
|
190
|
+
*/
|
|
191
|
+
TraceLogger._verboseLogManager = new LogManager();
|
|
192
|
+
TraceLogger._defaultLogger = new DefaultTraceHandler();
|
|
193
|
+
TraceLogger._shouldWriteToConsole = false;
|
|
194
|
+
return TraceLogger;
|
|
195
|
+
}());
|
|
196
|
+
export default TraceLogger;
|
|
197
|
+
//# sourceMappingURL=TraceLogger.js.map
|