@microsoft/sp-diagnostics 1.23.2 → 1.24.0-beta.3
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 +6 -11
- package/dist/index-internal-beta.d.ts +22 -0
- package/dist/index-internal-public.d.ts +22 -0
- package/dist/index-internal.d.ts +22 -0
- package/dist/sp-diagnostics_none_ebdbca9bc199b51d4466.js +1 -0
- package/dist/tsdoc-metadata.json +1 -1
- package/lib-commonjs/Api/Engagement/EngagementLogger.js +91 -96
- package/lib-commonjs/Api/Engagement/IEngagementHandler.js +9 -3
- package/lib-commonjs/Api/ExecutionQueue.js +73 -86
- package/lib-commonjs/Api/ILogData.js +6 -3
- package/lib-commonjs/Api/ILogEntry.js +5 -2
- package/lib-commonjs/Api/ILogErrorData.js +6 -3
- package/lib-commonjs/Api/ILogSource.js +10 -3
- package/lib-commonjs/Api/ILogVerboseData.js +6 -3
- package/lib-commonjs/Api/Log/LogHandler.js +27 -26
- package/lib-commonjs/Api/LogEntry.js +40 -39
- package/lib-commonjs/Api/LogFeature.js +14 -10
- package/lib-commonjs/Api/LogLevel.js +22 -19
- package/lib-commonjs/Api/LogManager/CircularBuffer.js +56 -64
- package/lib-commonjs/Api/LogManager/LogManager.js +61 -78
- package/lib-commonjs/Api/LogSource.js +37 -35
- package/lib-commonjs/Api/LogType.js +20 -15
- package/lib-commonjs/Api/Qos/AutoAlertableQosMonitor.js +68 -82
- package/lib-commonjs/Api/Qos/CustomerPromiseInterfaces/ICustomerPromiseErrorDetails.js +5 -2
- package/lib-commonjs/Api/Qos/CustomerPromiseInterfaces/IExtraDataForCustomerPromise.js +5 -2
- package/lib-commonjs/Api/Qos/IQos.js +5 -2
- package/lib-commonjs/Api/Qos/IQosEndEvent.js +5 -2
- package/lib-commonjs/Api/Qos/IQosExtraData.js +15 -3
- package/lib-commonjs/Api/Qos/IQosStartEvent.js +9 -3
- package/lib-commonjs/Api/Qos/QosLogger.js +54 -60
- package/lib-commonjs/Api/Qos/QosMonitor.js +163 -209
- package/lib-commonjs/Api/Qos/QosMonitorShareFailureWithCP.js +72 -92
- package/lib-commonjs/Api/Qos/QosResultType.js +14 -7
- package/lib-commonjs/Api/Trace/DefaultTraceHandler.js +20 -22
- package/lib-commonjs/Api/Trace/ITraceHandler.js +9 -3
- package/lib-commonjs/Api/Trace/ITraceLogger.js +5 -2
- package/lib-commonjs/Api/Trace/LogEvent.js +86 -125
- package/lib-commonjs/Api/Trace/TraceLogger.js +149 -161
- package/lib-commonjs/Diagnostics.js +68 -72
- package/lib-commonjs/DiagnosticsSettingsManager.js +48 -43
- package/lib-commonjs/IDiagnosticsSettings.js +5 -2
- package/lib-commonjs/common/Killswitches.js +13 -9
- package/lib-commonjs/extraData/DisplayApp.js +13 -5
- package/lib-commonjs/extraData/IDiagnosticContextInfo.js +5 -2
- package/lib-commonjs/extraData/IPageExtraData.js +5 -2
- package/lib-commonjs/extraData/PageType.js +15 -8
- package/lib-commonjs/extraData/PromotedState.js +18 -13
- package/lib-commonjs/extraData/WebTemplateId.js +13 -5
- package/lib-commonjs/extraData/setPageExtraData.js +37 -37
- package/lib-commonjs/index.js +102 -50
- package/{lib → lib-dts}/Api/Engagement/IEngagementHandler.d.ts +2 -0
- package/{lib → lib-dts}/Diagnostics.d.ts +11 -0
- package/{lib → lib-dts}/DiagnosticsSettingsManager.d.ts +4 -0
- package/lib-esm/Api/Engagement/EngagementLogger.js +137 -0
- package/lib-esm/Api/Engagement/IEngagementHandler.js +9 -0
- package/lib-esm/Api/ExecutionQueue.js +114 -0
- package/lib-esm/Api/ILogData.js +4 -0
- package/lib-esm/Api/ILogEntry.js +3 -0
- package/lib-esm/Api/ILogErrorData.js +4 -0
- package/lib-esm/Api/ILogSource.js +8 -0
- package/lib-esm/Api/ILogVerboseData.js +4 -0
- package/lib-esm/Api/Log/LogHandler.js +37 -0
- package/lib-esm/Api/LogEntry.js +44 -0
- package/lib-esm/Api/LogFeature.js +8 -0
- package/lib-esm/Api/LogLevel.js +20 -0
- package/lib-esm/Api/LogManager/CircularBuffer.js +83 -0
- package/lib-esm/Api/LogManager/LogManager.js +103 -0
- package/lib-esm/Api/LogSource.js +32 -0
- package/lib-esm/Api/LogType.js +20 -0
- package/lib-esm/Api/Qos/AutoAlertableQosMonitor.js +74 -0
- package/lib-esm/Api/Qos/CustomerPromiseInterfaces/ICustomerPromiseErrorDetails.js +6 -0
- package/lib-esm/Api/Qos/CustomerPromiseInterfaces/IExtraDataForCustomerPromise.js +6 -0
- package/lib-esm/Api/Qos/IQos.js +6 -0
- package/lib-esm/Api/Qos/IQosEndEvent.js +6 -0
- package/lib-esm/Api/Qos/IQosExtraData.js +12 -0
- package/lib-esm/Api/Qos/IQosStartEvent.js +6 -0
- package/lib-esm/Api/Qos/QosLogger.js +64 -0
- package/lib-esm/Api/Qos/QosMonitor.js +258 -0
- package/lib-esm/Api/Qos/QosMonitorShareFailureWithCP.js +89 -0
- package/lib-esm/Api/Qos/QosResultType.js +11 -0
- package/lib-esm/Api/Trace/DefaultTraceHandler.js +23 -0
- package/lib-esm/Api/Trace/ITraceHandler.js +9 -0
- package/lib-esm/Api/Trace/ITraceLogger.js +3 -0
- package/lib-esm/Api/Trace/LogEvent.js +104 -0
- package/lib-esm/Api/Trace/TraceLogger.js +180 -0
- package/lib-esm/Diagnostics.js +78 -0
- package/lib-esm/DiagnosticsSettingsManager.js +65 -0
- package/lib-esm/IDiagnosticsSettings.js +3 -0
- package/{lib → lib-esm}/common/Killswitches.js +3 -4
- package/{lib → lib-esm}/extraData/DisplayApp.js +3 -2
- package/lib-esm/extraData/IDiagnosticContextInfo.js +7 -0
- package/lib-esm/extraData/IPageExtraData.js +3 -0
- package/{lib → lib-esm}/extraData/PageType.js +4 -4
- package/lib-esm/extraData/PromotedState.js +15 -0
- package/{lib → lib-esm}/extraData/WebTemplateId.js +3 -2
- package/{lib → lib-esm}/extraData/setPageExtraData.js +14 -20
- package/{lib → lib-esm}/index.js +3 -3
- package/package.json +33 -6
- package/dist/sp-diagnostics_none_414da724f4073ce8bb98.js +0 -1
- package/lib/Api/Engagement/EngagementLogger.d.ts.map +0 -1
- package/lib/Api/Engagement/EngagementLogger.js +0 -143
- package/lib/Api/Engagement/IEngagementHandler.d.ts.map +0 -1
- package/lib/Api/Engagement/IEngagementHandler.js +0 -2
- package/lib/Api/ExecutionQueue.d.ts.map +0 -1
- package/lib/Api/ExecutionQueue.js +0 -131
- package/lib/Api/ILogData.d.ts.map +0 -1
- package/lib/Api/ILogData.js +0 -3
- package/lib/Api/ILogEntry.d.ts.map +0 -1
- package/lib/Api/ILogEntry.js +0 -2
- package/lib/Api/ILogErrorData.d.ts.map +0 -1
- package/lib/Api/ILogErrorData.js +0 -3
- package/lib/Api/ILogSource.d.ts.map +0 -1
- package/lib/Api/ILogSource.js +0 -3
- package/lib/Api/ILogVerboseData.d.ts.map +0 -1
- package/lib/Api/ILogVerboseData.js +0 -3
- package/lib/Api/Log/LogHandler.d.ts.map +0 -1
- package/lib/Api/Log/LogHandler.js +0 -40
- package/lib/Api/LogEntry.d.ts.map +0 -1
- package/lib/Api/LogEntry.js +0 -51
- package/lib/Api/LogFeature.d.ts.map +0 -1
- package/lib/Api/LogFeature.js +0 -11
- package/lib/Api/LogLevel.d.ts.map +0 -1
- package/lib/Api/LogLevel.js +0 -24
- package/lib/Api/LogManager/CircularBuffer.d.ts.map +0 -1
- package/lib/Api/LogManager/CircularBuffer.js +0 -98
- package/lib/Api/LogManager/LogManager.d.ts.map +0 -1
- package/lib/Api/LogManager/LogManager.js +0 -121
- package/lib/Api/LogSource.d.ts.map +0 -1
- package/lib/Api/LogSource.js +0 -40
- package/lib/Api/LogType.d.ts.map +0 -1
- package/lib/Api/LogType.js +0 -23
- package/lib/Api/Qos/AutoAlertableQosMonitor.d.ts.map +0 -1
- package/lib/Api/Qos/AutoAlertableQosMonitor.js +0 -93
- package/lib/Api/Qos/CustomerPromiseInterfaces/ICustomerPromiseErrorDetails.d.ts.map +0 -1
- package/lib/Api/Qos/CustomerPromiseInterfaces/ICustomerPromiseErrorDetails.js +0 -2
- package/lib/Api/Qos/CustomerPromiseInterfaces/IExtraDataForCustomerPromise.d.ts.map +0 -1
- package/lib/Api/Qos/CustomerPromiseInterfaces/IExtraDataForCustomerPromise.js +0 -2
- package/lib/Api/Qos/IQos.d.ts.map +0 -1
- package/lib/Api/Qos/IQos.js +0 -2
- package/lib/Api/Qos/IQosEndEvent.d.ts.map +0 -1
- package/lib/Api/Qos/IQosEndEvent.js +0 -2
- package/lib/Api/Qos/IQosExtraData.d.ts.map +0 -1
- package/lib/Api/Qos/IQosExtraData.js +0 -2
- package/lib/Api/Qos/IQosStartEvent.d.ts.map +0 -1
- package/lib/Api/Qos/IQosStartEvent.js +0 -2
- package/lib/Api/Qos/QosLogger.d.ts.map +0 -1
- package/lib/Api/Qos/QosLogger.js +0 -74
- package/lib/Api/Qos/QosMonitor.d.ts.map +0 -1
- package/lib/Api/Qos/QosMonitor.js +0 -304
- package/lib/Api/Qos/QosMonitorShareFailureWithCP.d.ts.map +0 -1
- package/lib/Api/Qos/QosMonitorShareFailureWithCP.js +0 -114
- package/lib/Api/Qos/QosResultType.d.ts.map +0 -1
- package/lib/Api/Qos/QosResultType.js +0 -11
- package/lib/Api/Trace/DefaultTraceHandler.d.ts.map +0 -1
- package/lib/Api/Trace/DefaultTraceHandler.js +0 -30
- package/lib/Api/Trace/ITraceHandler.d.ts.map +0 -1
- package/lib/Api/Trace/ITraceHandler.js +0 -2
- package/lib/Api/Trace/ITraceLogger.d.ts.map +0 -1
- package/lib/Api/Trace/ITraceLogger.js +0 -2
- package/lib/Api/Trace/LogEvent.d.ts.map +0 -1
- package/lib/Api/Trace/LogEvent.js +0 -147
- package/lib/Api/Trace/TraceLogger.d.ts.map +0 -1
- package/lib/Api/Trace/TraceLogger.js +0 -196
- package/lib/Diagnostics.d.ts.map +0 -1
- package/lib/Diagnostics.js +0 -82
- package/lib/DiagnosticsSettingsManager.d.ts.map +0 -1
- package/lib/DiagnosticsSettingsManager.js +0 -62
- package/lib/IDiagnosticsSettings.d.ts.map +0 -1
- package/lib/IDiagnosticsSettings.js +0 -2
- package/lib/common/Killswitches.d.ts.map +0 -1
- package/lib/extraData/DisplayApp.d.ts.map +0 -1
- package/lib/extraData/IDiagnosticContextInfo.d.ts.map +0 -1
- package/lib/extraData/IDiagnosticContextInfo.js +0 -2
- package/lib/extraData/IPageExtraData.d.ts.map +0 -1
- package/lib/extraData/IPageExtraData.js +0 -2
- package/lib/extraData/PageType.d.ts.map +0 -1
- package/lib/extraData/PromotedState.d.ts.map +0 -1
- package/lib/extraData/PromotedState.js +0 -17
- package/lib/extraData/WebTemplateId.d.ts.map +0 -1
- package/lib/extraData/setPageExtraData.d.ts.map +0 -1
- package/lib/index.d.ts.map +0 -1
- /package/{lib → lib-dts}/Api/Engagement/EngagementLogger.d.ts +0 -0
- /package/{lib → lib-dts}/Api/ExecutionQueue.d.ts +0 -0
- /package/{lib → lib-dts}/Api/ILogData.d.ts +0 -0
- /package/{lib → lib-dts}/Api/ILogEntry.d.ts +0 -0
- /package/{lib → lib-dts}/Api/ILogErrorData.d.ts +0 -0
- /package/{lib → lib-dts}/Api/ILogSource.d.ts +0 -0
- /package/{lib → lib-dts}/Api/ILogVerboseData.d.ts +0 -0
- /package/{lib → lib-dts}/Api/Log/LogHandler.d.ts +0 -0
- /package/{lib → lib-dts}/Api/LogEntry.d.ts +0 -0
- /package/{lib → lib-dts}/Api/LogFeature.d.ts +0 -0
- /package/{lib → lib-dts}/Api/LogLevel.d.ts +0 -0
- /package/{lib → lib-dts}/Api/LogManager/CircularBuffer.d.ts +0 -0
- /package/{lib → lib-dts}/Api/LogManager/LogManager.d.ts +0 -0
- /package/{lib → lib-dts}/Api/LogSource.d.ts +0 -0
- /package/{lib → lib-dts}/Api/LogType.d.ts +0 -0
- /package/{lib → lib-dts}/Api/Qos/AutoAlertableQosMonitor.d.ts +0 -0
- /package/{lib → lib-dts}/Api/Qos/CustomerPromiseInterfaces/ICustomerPromiseErrorDetails.d.ts +0 -0
- /package/{lib → lib-dts}/Api/Qos/CustomerPromiseInterfaces/IExtraDataForCustomerPromise.d.ts +0 -0
- /package/{lib → lib-dts}/Api/Qos/IQos.d.ts +0 -0
- /package/{lib → lib-dts}/Api/Qos/IQosEndEvent.d.ts +0 -0
- /package/{lib → lib-dts}/Api/Qos/IQosExtraData.d.ts +0 -0
- /package/{lib → lib-dts}/Api/Qos/IQosStartEvent.d.ts +0 -0
- /package/{lib → lib-dts}/Api/Qos/QosLogger.d.ts +0 -0
- /package/{lib → lib-dts}/Api/Qos/QosMonitor.d.ts +0 -0
- /package/{lib → lib-dts}/Api/Qos/QosMonitorShareFailureWithCP.d.ts +0 -0
- /package/{lib → lib-dts}/Api/Qos/QosResultType.d.ts +0 -0
- /package/{lib → lib-dts}/Api/Trace/DefaultTraceHandler.d.ts +0 -0
- /package/{lib → lib-dts}/Api/Trace/ITraceHandler.d.ts +0 -0
- /package/{lib → lib-dts}/Api/Trace/ITraceLogger.d.ts +0 -0
- /package/{lib → lib-dts}/Api/Trace/LogEvent.d.ts +0 -0
- /package/{lib → lib-dts}/Api/Trace/TraceLogger.d.ts +0 -0
- /package/{lib → lib-dts}/IDiagnosticsSettings.d.ts +0 -0
- /package/{lib → lib-dts}/common/Killswitches.d.ts +0 -0
- /package/{lib → lib-dts}/extraData/DisplayApp.d.ts +0 -0
- /package/{lib → lib-dts}/extraData/IDiagnosticContextInfo.d.ts +0 -0
- /package/{lib → lib-dts}/extraData/IPageExtraData.d.ts +0 -0
- /package/{lib → lib-dts}/extraData/PageType.d.ts +0 -0
- /package/{lib → lib-dts}/extraData/PromotedState.d.ts +0 -0
- /package/{lib → lib-dts}/extraData/WebTemplateId.d.ts +0 -0
- /package/{lib → lib-dts}/extraData/setPageExtraData.d.ts +0 -0
- /package/{lib → lib-dts}/index.d.ts +0 -0
- /package/{lib → lib-esm}/sp-diagnostics.manifest.json +0 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
class ExecutionQueue {
|
|
2
|
+
/**
|
|
3
|
+
* Determines if the added execution entries should be processed in real time.
|
|
4
|
+
* If this is set to true, a stack with entries will not be saved.
|
|
5
|
+
*
|
|
6
|
+
* When set to true, all entries on stack will be processed and future entries
|
|
7
|
+
* will be executed in real time.
|
|
8
|
+
* When set to false, future entries will be saved in the execution stack for
|
|
9
|
+
* later processing.
|
|
10
|
+
*/ get shouldExecuteInRealTime() {
|
|
11
|
+
return this._shouldExecuteInRealTime;
|
|
12
|
+
}
|
|
13
|
+
set shouldExecuteInRealTime(executeInRealTime) {
|
|
14
|
+
this._shouldExecuteInRealTime = executeInRealTime;
|
|
15
|
+
if (this._shouldExecuteInRealTime) {
|
|
16
|
+
this.flush();
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Registers an external handler to collection for delayed asynchronous processing.
|
|
21
|
+
* Handlers are registered once. If handler is already registered, it does nothing.
|
|
22
|
+
*/ addHandler(key, handler) {
|
|
23
|
+
if (this._containsHandler(key, handler)) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
this._initializeHandlerArrayForKey(key);
|
|
27
|
+
const handlers = this._handlers[key];
|
|
28
|
+
if (handlers.indexOf(handler) === -1) {
|
|
29
|
+
handlers.push(handler);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Execution Entry registration for delayed asynchronous processing.
|
|
34
|
+
*/ addExecutionEntry(key, ...args) {
|
|
35
|
+
Object.freeze(args);
|
|
36
|
+
if (this._shouldExecuteInRealTime) {
|
|
37
|
+
this._processExecutionEntry(key, args);
|
|
38
|
+
} else {
|
|
39
|
+
this._executionEntries.push({
|
|
40
|
+
key: key,
|
|
41
|
+
args: args
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Removes an external executionEntry handler from collection for asynchronous event logging.
|
|
47
|
+
* Logger is registered once.
|
|
48
|
+
*/ removeHandler(key, handler) {
|
|
49
|
+
const index = this._handlers[key].indexOf(handler);
|
|
50
|
+
if (index > -1) {
|
|
51
|
+
this._handlers[key].splice(index, 1);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Reset function clears executionEntry handler collection for asynchronous event logging.
|
|
56
|
+
* All recorded execution entries and handlers are purged.
|
|
57
|
+
*/ reset() {
|
|
58
|
+
this._handlers = {};
|
|
59
|
+
this._executionEntries = [];
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Flushes all the buffered execution entries.
|
|
63
|
+
* All recorded execution entries are purged.
|
|
64
|
+
*/ flush() {
|
|
65
|
+
this._processAllExecutionEntries();
|
|
66
|
+
this._executionEntries = [];
|
|
67
|
+
}
|
|
68
|
+
_containsHandler(key, handler) {
|
|
69
|
+
if (this._handlers[key] !== null && this._handlers[key] !== undefined) {
|
|
70
|
+
return this._handlers[key].indexOf(handler) > -1;
|
|
71
|
+
}
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
_initializeHandlerArrayForKey(key) {
|
|
75
|
+
if (this._handlers[key] === null || this._handlers[key] === undefined) {
|
|
76
|
+
this._handlers[key] = [];
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
_processAllExecutionEntries() {
|
|
80
|
+
for (const entry of this._executionEntries){
|
|
81
|
+
if (entry && this._handlers[entry.key]) {
|
|
82
|
+
try {
|
|
83
|
+
for (const handler of this._handlers[entry.key]){
|
|
84
|
+
handler.apply(this, entry.args);
|
|
85
|
+
}
|
|
86
|
+
} catch (e) {
|
|
87
|
+
// eslint-disable-next-line no-console
|
|
88
|
+
console.error('failed to process execution entry:' + e.toString());
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
_processExecutionEntry(key, args) {
|
|
94
|
+
for(let i = 0; i < this._handlers[key].length; i++){
|
|
95
|
+
try {
|
|
96
|
+
this._handlers[key][i].apply(this, args);
|
|
97
|
+
} catch (e) {
|
|
98
|
+
// eslint-disable-next-line no-console
|
|
99
|
+
console.error('failed to process execution entry:' + e.toString());
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
constructor(){
|
|
104
|
+
this._shouldExecuteInRealTime = false;
|
|
105
|
+
this._handlers = {};
|
|
106
|
+
this._executionEntries = [];
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* ExecutionQueue allows multiple handlers to be processed in real time or deferred.
|
|
111
|
+
* @internal
|
|
112
|
+
*/ export { ExecutionQueue as default };
|
|
113
|
+
|
|
114
|
+
//# sourceMappingURL=./ExecutionQueue.js.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { LogLevel } from '../LogLevel';
|
|
2
|
+
import LogEvent from '../Trace/LogEvent';
|
|
3
|
+
class LogHandler {
|
|
4
|
+
verbose(source, message, scope) {
|
|
5
|
+
const event = LogEvent.log(source, message, LogLevel.Verbose, scope);
|
|
6
|
+
if (DEBUG && !DEPRECATED_UNIT_TEST) {
|
|
7
|
+
// eslint-disable-next-line no-console
|
|
8
|
+
console.log(event.toString());
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
info(source, message, scope) {
|
|
12
|
+
const event = LogEvent.log(source, message, LogLevel.Info, scope);
|
|
13
|
+
if (DEBUG && !DEPRECATED_UNIT_TEST) {
|
|
14
|
+
console.info(event.toString());
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
warn(source, message, scope) {
|
|
18
|
+
const event = LogEvent.log(source, message, LogLevel.Warning, scope);
|
|
19
|
+
if (DEBUG && !DEPRECATED_UNIT_TEST) {
|
|
20
|
+
// eslint-disable-next-line no-console
|
|
21
|
+
console.warn(event.toString());
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
error(source, error, scope) {
|
|
25
|
+
const event = LogEvent.log(source, error, LogLevel.Error, scope);
|
|
26
|
+
if (DEBUG && !DEPRECATED_UNIT_TEST) {
|
|
27
|
+
// eslint-disable-next-line no-console
|
|
28
|
+
console.error(event.toString());
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* This handler adapts the sp-core-library Log to use the internal telemetry.
|
|
34
|
+
* @internal
|
|
35
|
+
*/ export { LogHandler as default };
|
|
36
|
+
|
|
37
|
+
//# sourceMappingURL=./LogHandler.js.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Copyright (c) Microsoft. All rights reserved.
|
|
2
|
+
import LogFeature from './LogFeature';
|
|
3
|
+
import LogType from './LogType';
|
|
4
|
+
/**
|
|
5
|
+
* Represents a Log entry
|
|
6
|
+
*
|
|
7
|
+
* @internal
|
|
8
|
+
*/ class LogEntry {
|
|
9
|
+
/**
|
|
10
|
+
* convert the log entry to string
|
|
11
|
+
* @returns the serialized log entry
|
|
12
|
+
*/ toString() {
|
|
13
|
+
let serializedLogProps = undefined;
|
|
14
|
+
if (this.logProperties) {
|
|
15
|
+
try {
|
|
16
|
+
serializedLogProps = JSON.stringify(this.logProperties);
|
|
17
|
+
} catch (e) {
|
|
18
|
+
// eslint-disable-next-line no-console
|
|
19
|
+
console.log('Error happens in toString():' + e);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return `${this.moduleName} | ${this.logFeature} | ${this.logType} | ${serializedLogProps}`;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Initializes a new instance of LogEntry
|
|
26
|
+
* @param moduleName - the name of the module
|
|
27
|
+
* @param logFeature - the name of the feature
|
|
28
|
+
* @param logType - the log type
|
|
29
|
+
* @param logProperties - optional property bag
|
|
30
|
+
*/ constructor(moduleName, logFeature = LogFeature.None, logType = LogType.Trace, logProperties, isIntentional){
|
|
31
|
+
if (moduleName) {
|
|
32
|
+
this.moduleName = moduleName;
|
|
33
|
+
this.logFeature = logFeature;
|
|
34
|
+
this.logType = logType;
|
|
35
|
+
this.logProperties = logProperties;
|
|
36
|
+
this.isIntentional = isIntentional;
|
|
37
|
+
} else {
|
|
38
|
+
throw new Error('moduleName is invalid');
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
export default LogEntry;
|
|
43
|
+
|
|
44
|
+
//# sourceMappingURL=./LogEntry.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LogLevel represents the level of a log event.
|
|
3
|
+
* @internal
|
|
4
|
+
*/ export var LogLevel;
|
|
5
|
+
(function(LogLevel) {
|
|
6
|
+
/**
|
|
7
|
+
* verbose event for debugging
|
|
8
|
+
*/ LogLevel[LogLevel["Verbose"] = 1] = "Verbose";
|
|
9
|
+
/**
|
|
10
|
+
* Informational event
|
|
11
|
+
*/ LogLevel[LogLevel["Info"] = 2] = "Info";
|
|
12
|
+
/**
|
|
13
|
+
* A warning
|
|
14
|
+
*/ LogLevel[LogLevel["Warning"] = 3] = "Warning";
|
|
15
|
+
/**
|
|
16
|
+
* An error
|
|
17
|
+
*/ LogLevel[LogLevel["Error"] = 4] = "Error";
|
|
18
|
+
})(LogLevel || (LogLevel = {}));
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=./LogLevel.js.map
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @internal
|
|
3
|
+
*/ class CircularBuffer {
|
|
4
|
+
get count() {
|
|
5
|
+
return this._count;
|
|
6
|
+
}
|
|
7
|
+
push(item) {
|
|
8
|
+
this._ensureNotIterating();
|
|
9
|
+
this._head++;
|
|
10
|
+
this._count++;
|
|
11
|
+
if (this._head === this._size) {
|
|
12
|
+
this._head = 0;
|
|
13
|
+
}
|
|
14
|
+
this._buffer[this._head] = item;
|
|
15
|
+
}
|
|
16
|
+
forEach(handle) {
|
|
17
|
+
if (this._count === 0) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
this._isIterating = true;
|
|
21
|
+
try {
|
|
22
|
+
let current = this._tail;
|
|
23
|
+
// For-loop is prefered over while loop here to avoid possible infinite loop.
|
|
24
|
+
for(let i = 0; i < this._size; i++){
|
|
25
|
+
handle(this._buffer[current]);
|
|
26
|
+
if (current === this._head) {
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
current = this._getNext(current);
|
|
30
|
+
}
|
|
31
|
+
} finally{
|
|
32
|
+
this._isIterating = false;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
removeAll() {
|
|
36
|
+
this._ensureNotIterating();
|
|
37
|
+
this._head = -1;
|
|
38
|
+
this._count = 0;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Index of the oldest item in the buffer
|
|
42
|
+
*/ get _tail() {
|
|
43
|
+
if (this._isNotWrapped()) {
|
|
44
|
+
return 0;
|
|
45
|
+
}
|
|
46
|
+
return this._getNext(this._head);
|
|
47
|
+
}
|
|
48
|
+
_isNotWrapped() {
|
|
49
|
+
return this._count === this._head + 1;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The next index should be index + 1, unless it reaches
|
|
53
|
+
* the end of the buffer and needs to rewind to 0.
|
|
54
|
+
*/ _getNext(index) {
|
|
55
|
+
let nextIndex = index + 1;
|
|
56
|
+
if (nextIndex === this._size) {
|
|
57
|
+
nextIndex = 0;
|
|
58
|
+
}
|
|
59
|
+
return nextIndex;
|
|
60
|
+
}
|
|
61
|
+
_ensureNotIterating() {
|
|
62
|
+
if (this._isIterating) {
|
|
63
|
+
throw new Error('Circular buffer cannot be modified during iteration');
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
constructor(size){
|
|
67
|
+
/**
|
|
68
|
+
* Index of the newest item in the buffer
|
|
69
|
+
*/ this._head = -1;
|
|
70
|
+
/**
|
|
71
|
+
* The overall count of how many items have ever been added to the buffer.
|
|
72
|
+
*/ this._count = 0;
|
|
73
|
+
this._isIterating = false;
|
|
74
|
+
if (size <= 0) {
|
|
75
|
+
throw new Error('Size must be positive');
|
|
76
|
+
}
|
|
77
|
+
this._size = size;
|
|
78
|
+
this._buffer = new Array(size);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
export { CircularBuffer as default };
|
|
82
|
+
|
|
83
|
+
//# sourceMappingURL=./CircularBuffer.js.map
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import CircularBuffer from './CircularBuffer';
|
|
2
|
+
class LogManager {
|
|
3
|
+
static get _maxVerboseLog() {
|
|
4
|
+
return 5000;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Event list for delayed asynchronous processing.
|
|
8
|
+
* Events are accumulated in CircularBuffer for processing later.
|
|
9
|
+
*/ get events() {
|
|
10
|
+
return this._events;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Registers an external logger to logger collection for asynchronous event logging.
|
|
14
|
+
* Logger is registered once.
|
|
15
|
+
*/ addHandler(handler) {
|
|
16
|
+
if (!this._containsHandler(handler)) {
|
|
17
|
+
this._handlers.push(handler);
|
|
18
|
+
this._shouldLogInRealTime.push(false);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Event logging operation for delayed asynchronous processing.
|
|
23
|
+
*/ log(event) {
|
|
24
|
+
Object.freeze(event);
|
|
25
|
+
this._events.push(event);
|
|
26
|
+
this._processLogEvent(event);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Removes an external logger from logger collection for asynchronous event logging.
|
|
30
|
+
* Logger is registered once.
|
|
31
|
+
*/ removeHandler(handler) {
|
|
32
|
+
const index = this._handlers.indexOf(handler);
|
|
33
|
+
if (index > -1) {
|
|
34
|
+
this._handlers.splice(index, 1);
|
|
35
|
+
this._shouldLogInRealTime.splice(index, 1);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Reset function clears logger collection for asynchronous event logging.
|
|
40
|
+
* All recorded events are purged.
|
|
41
|
+
*/ reset() {
|
|
42
|
+
this._handlers = [];
|
|
43
|
+
this._shouldLogInRealTime = [];
|
|
44
|
+
this._events.removeAll();
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Processes all the buffered events using the registered handler.
|
|
48
|
+
*/ processAll(handler) {
|
|
49
|
+
if (this._handlers.indexOf(handler) > -1) {
|
|
50
|
+
this._processAllEvents(handler);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
_containsHandler(handler) {
|
|
54
|
+
for (const existingHandler of this._handlers){
|
|
55
|
+
if (existingHandler === handler) {
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
_processAllEvents(handler) {
|
|
62
|
+
this._events.forEach((event)=>{
|
|
63
|
+
if (event) {
|
|
64
|
+
try {
|
|
65
|
+
handler(event);
|
|
66
|
+
} catch (e) {
|
|
67
|
+
// eslint-disable-next-line no-console
|
|
68
|
+
console.error('failed to handle event:' + e.toString());
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
this._shouldLogInRealTime[this._handlers.indexOf(handler)] = true;
|
|
73
|
+
}
|
|
74
|
+
_processLogEvent(event) {
|
|
75
|
+
for(let i = 0; i < this._handlers.length; i++){
|
|
76
|
+
if (this._shouldLogInRealTime[i] && event) {
|
|
77
|
+
try {
|
|
78
|
+
this._handlers[i](event);
|
|
79
|
+
} catch (e) {
|
|
80
|
+
// eslint-disable-next-line no-console
|
|
81
|
+
console.error('failed to handle event:' + e.toString());
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
constructor(initialHandler){
|
|
87
|
+
this._shouldLogInRealTime = [];
|
|
88
|
+
this._handlers = [];
|
|
89
|
+
this._events = new CircularBuffer(LogManager._maxVerboseLog);
|
|
90
|
+
if (initialHandler) {
|
|
91
|
+
this.addHandler(initialHandler);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* LogManager allows multiple handlers to process log events.
|
|
97
|
+
* It caches the latest 5000 log events. If a handler is just added, the
|
|
98
|
+
* handler is able to get access to the cached events and all incoming events.
|
|
99
|
+
* Dev-dashboard and potentially third-party can use it to get access to events.
|
|
100
|
+
* @internal
|
|
101
|
+
*/ export { LogManager as default };
|
|
102
|
+
|
|
103
|
+
//# sourceMappingURL=./LogManager.js.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Copyright (c) Microsoft. All rights reserved.
|
|
2
|
+
import { ServiceKey, Validate } from '@microsoft/sp-core-library';
|
|
3
|
+
class LogSource {
|
|
4
|
+
/**
|
|
5
|
+
* Factory method to create an instance of the LogSource class
|
|
6
|
+
* @returns a reference to an instance of the LogSource class
|
|
7
|
+
*/ static create(id) {
|
|
8
|
+
return new LogSource(id);
|
|
9
|
+
}
|
|
10
|
+
get id() {
|
|
11
|
+
return this._id;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* @returns if the LogSource is empty.
|
|
15
|
+
*/ isEmpty() {
|
|
16
|
+
return this._id.length === 0;
|
|
17
|
+
}
|
|
18
|
+
constructor(id){
|
|
19
|
+
Validate.isNotNullOrUndefined(id, 'id');
|
|
20
|
+
this._id = id;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Represents a Log entry
|
|
25
|
+
*
|
|
26
|
+
* @internal
|
|
27
|
+
*/ export { LogSource as default };
|
|
28
|
+
/** @internal */ export const logSourceServiceKey = ServiceKey.createCustom('sp-client-base:LogSource', (serviceScope)=>{
|
|
29
|
+
return LogSource.create('');
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=./LogSource.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Copyright (c) Microsoft. All rights reserved.
|
|
2
|
+
/**
|
|
3
|
+
* Represents the supported log types
|
|
4
|
+
*
|
|
5
|
+
* @internal
|
|
6
|
+
*/ var LogType;
|
|
7
|
+
(function(LogType) {
|
|
8
|
+
/**
|
|
9
|
+
* Trace level log. Use this for logging diagnostics
|
|
10
|
+
*/ LogType[LogType["Trace"] = 1] = "Trace";
|
|
11
|
+
/**
|
|
12
|
+
* Event level log. Use this for logging usage etc
|
|
13
|
+
*/ LogType[LogType["Event"] = 2] = "Event";
|
|
14
|
+
/**
|
|
15
|
+
* Use for errors
|
|
16
|
+
*/ LogType[LogType["Error"] = 3] = "Error";
|
|
17
|
+
})(LogType || (LogType = {}));
|
|
18
|
+
export default LogType;
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=./LogType.js.map
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import QosMonitor from './QosMonitor';
|
|
2
|
+
/**
|
|
3
|
+
* Object members correspond to auto alerting monitors.
|
|
4
|
+
* Information about monitors: https://onedrive.visualstudio.com/WEX!/_wiki/wikis/WEX!.wiki/30583/Current-Monitors
|
|
5
|
+
*
|
|
6
|
+
* @internal
|
|
7
|
+
*/ // eslint-disable-next-line @typescript-eslint/typedef
|
|
8
|
+
export const AutoAlertableMonitorType = {
|
|
9
|
+
/**
|
|
10
|
+
* If QoS drops below a static threshold of 95 for a period, a sev 4 is fired.
|
|
11
|
+
*/ StaticReliabilityQos95Sev4: 'StaticReliabilityQos95Sev4',
|
|
12
|
+
/**
|
|
13
|
+
* If QoS drops below some dynamic threshold "Medium" sensitivity (as defined by Geneva)
|
|
14
|
+
* calculated from historical monitor data, a sev 4 is fired.
|
|
15
|
+
*/ DynamicReliabilityQosMediumSev4: 'DynamicReliabilityQosMediumSev4',
|
|
16
|
+
/**
|
|
17
|
+
* If the number of expected errors increases past a "High" dynamic threshold sensitivity
|
|
18
|
+
* (as defined by Geneva) calculated from historical monitor data OR QoS drops below some
|
|
19
|
+
* dynamic threshold "Medium" sensitivity, a sev 4 is fired.
|
|
20
|
+
*/ DynamicReliabilityExpectedFailureHighSev4: 'DynamicReliabilityExpectedFailureHighSev4'
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Qos logger which enforces using an existing altering monitor as determined by the
|
|
24
|
+
* AlertableMonitorType.
|
|
25
|
+
*
|
|
26
|
+
* @internal
|
|
27
|
+
*/ export class AutoAlertableQosMonitor extends QosMonitor {
|
|
28
|
+
/**
|
|
29
|
+
* QoS monitor ends with success. Also writes AutoAlertableMonitorType to extraData.
|
|
30
|
+
* You will see success tag: SPPages.ScenarioName.Success
|
|
31
|
+
*/ // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
32
|
+
writeSuccess(extraData) {
|
|
33
|
+
super.writeSuccess(this._getExtraDataWithAutoAlertableFields(extraData));
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* QoS monitor ends with failure. Also writes AutoAlertableMonitorType to extraData.
|
|
37
|
+
* You will see failure tag: SPPages.ScenarioName.<failuretag>.Failure.
|
|
38
|
+
* <failuretag> will be filled with param tagName
|
|
39
|
+
*/ writeUnexpectedFailure(tagNameSuffix = 'DefaultUnexpected', ex, // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
40
|
+
extraData) {
|
|
41
|
+
super.writeUnexpectedFailure(tagNameSuffix, ex, this._getExtraDataWithAutoAlertableFields(extraData));
|
|
42
|
+
}
|
|
43
|
+
/*
|
|
44
|
+
* QoS monitor ends with expected failure. Also writes AutoAlertableMonitorType to extraData.
|
|
45
|
+
* You will see success tag: ModernPublish.RenderPublishPage.<failuretag>.ExpectedFailure.
|
|
46
|
+
* <failuretag> will be filled with param tagName
|
|
47
|
+
*/ writeExpectedFailure(tagNameSuffix = 'DefaultExpected', ex, // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
48
|
+
extraData) {
|
|
49
|
+
super.writeExpectedFailure(tagNameSuffix, ex, this._getExtraDataWithAutoAlertableFields(extraData));
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Gets the extraData with additional auto alertable dimensions to indicate this uses the easy
|
|
53
|
+
* alerting monitors.
|
|
54
|
+
*/ // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
55
|
+
_getExtraDataWithAutoAlertableFields(extraData) {
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
57
|
+
const returnedExtraData = extraData ?? {};
|
|
58
|
+
returnedExtraData.autoAlertableMonitorType = AutoAlertableMonitorType[this._autoAlertableMonitorType];
|
|
59
|
+
return returnedExtraData;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Creates a QoS monitor (initializes it and logs the start event) that enforces that end events
|
|
63
|
+
* fired include the alertableMonitorType property in extraData corresponding to the
|
|
64
|
+
*
|
|
65
|
+
* @param scenarioName - Unique name of the QoS scenario
|
|
66
|
+
* @param autoAlertableMonitorType - Correspond to existing alerting monitor that will track the events.
|
|
67
|
+
* @param copyToEngagement - Indicate whether this data should be used as Engagement as well.
|
|
68
|
+
*/ constructor(scenarioName, autoAlertableMonitorType, copyToEngagement = false){
|
|
69
|
+
super(scenarioName, /* copyToCosmos */ false, /* copyToInterana */ copyToEngagement);
|
|
70
|
+
this._autoAlertableMonitorType = autoAlertableMonitorType;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
//# sourceMappingURL=./AutoAlertableQosMonitor.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface for SPFx QoS extraData field.
|
|
3
|
+
* This provides schema validation through the interface to consolidate all extra data in a known set of fields.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* The goal of this interface is to provide a comprehensive list of extra data fields and encourage re-use, even if
|
|
7
|
+
* it's used in a different context.
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
*/ export { };
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=./IQosExtraData.js.map
|