1//// Wrapper class for client logger for below purposes 2//// 1. Abstracting CST framework code from manual trace log APIs. 3//// 2. Constrolling instantiation of CST framework code in clientLogger.js based on whether telemetry is enabled 4class ClientLogWrapper { 5 6 /// Constructor which also creates an instance of actual logger if telemetry is enabled 7 constructor() { 8 try { 9 if (Helper.isTelemetryEnabled()) { 10 ClientLogger.getLogger(); 11 } 12 } 13 catch (exception) { 14 console.warn(exception); 15 } 16 } 17 18 /// Gets the client log wrapper. Creates new instance if not already created 19 static getLogger() { 20 if (!window.clientLogWrapper) { 21 window.clientLogWrapper = new ClientLogWrapper(); 22 } 23 24 return window.clientLogWrapper; 25 } 26 27 /// Trace info log 28 /// For component, subComponent, action, tag, it is recommended to use standard short and crisp one worder string. 29 /// Examples: 30 /// for component: entity_grid, entity_form etc 31 /// For SubComponent: filter etc 32 /// For tag: RenderGrid etc 33 /// For action: Render etc 34 traceInfo(message, component, subComponent = "", action = "", tag = "", contextInfo = {}) { 35 try { 36 if (Helper.isTelemetryEnabled()) { 37 return ClientLogger.getLogger().traceInfo(message, component, subComponent, action, tag, contextInfo); 38 } 39 } 40 catch (exception) { 41 console.warn(exception); 42 } 43 } 44 45 /// Trace warning log 46 /// For component, subComponent, action, tag, it is recommended to use standard short and crisp one worder string. 47 /// Examples: 48 /// for component: entity_grid, entity_form etc 49 /// For SubComponent: filter etc 50 /// For tag: RenderGrid etc 51 /// For action: Render etc 52 traceWarning(message, component, subComponent = "", action = "", tag = "", contextInfo = {}) { 53 try { 54 if (Helper.isTelemetryEnabled()) { 55 return ClientLogger.getLogger().traceWarning(message, component, subComponent, action, tag, contextInfo); 56 } 57 } 58 catch (exception) { 59 console.warn(exception); 60 } 61 } 62 63 /// Trace error log 64 /// For component, subComponent, action, tag, it is recommended to use standard short and crisp one worder string. 65 /// Examples: 66 /// for component: entity_grid, entity_form etc 67 /// For SubComponent: filter etc 68 /// For tag: RenderGrid etc 69 /// For action: Render etc 70 traceError(message, component, subComponent = "", action = "", tag = "", contextInfo = {}) { 71 try { 72 if (Helper.isTelemetryEnabled()) { 73 return ClientLogger.getLogger().traceError(message, component, subComponent, action, tag, contextInfo); 74 } 75 } 76 catch (exception) { 77 console.warn(exception); 78 } 79 } 80 81 /// Trace server error log 82 /// For component, subComponent, action, tag, it is recommended to use standard short and crisp one worder string. 83 traceServerError(message, component, subComponent = "", action = "", tag = "", contextInfo = {}) { 84 try { 85 if (Helper.isTelemetryEnabled()) { 86 return ClientLogger.getLogger().traceServerError(message, component, subComponent, action, tag, contextInfo); 87 } 88 } 89 catch (exception) { 90 console.warn(exception); 91 } 92 } 93 94 /// Get wrapper for block perf tracker 95 getBlockPerfTracker() { 96 try { 97 return new BlockPerfTrackWrapper(); 98 } 99 catch (exception) { 100 console.warn(exception); 101 } 102 } 103} 104 105/// Helper for CST common utilities 106class Helper { 107 /// Checks whether telemetry is enabled 108 static isTelemetryEnabled() { 109 if (window["Microsoft"].Dynamic365.Portal.isTelemetryEnabled.toUpperCase() == "TRUE") { 110 return true; 111 } else { 112 return false; 113 } 114 } 115} 116 117/// Nested class as wrapper of block perf tracker 118class BlockPerfTrackWrapper { 119 120 /// Constructor that helps create block perf tracker if telemetry is enabled 121 constructor() { 122 if (Helper.isTelemetryEnabled()) { 123 this.blockPerfTracker = ClientLogger.getLogger().getBlockPerfTracker(); 124 } 125 } 126 127 /// Start the timer and set required details for tracking 128 /// For perfTag, component, subComponent, action, , it is recommended to use standard short and crisp one worder string. 129 /// Examples: 130 /// For perfTag: RenderGrid etc 131 /// for component: entity_grid, entity_form etc 132 /// For SubComponent: filter etc 133 /// For action: Render etc 134 start(perfTag, component, subComponent = "", action = "", message = "", contextInfo = {}) { 135 try { 136 if (Helper.isTelemetryEnabled()) { 137 return this.blockPerfTracker.start(perfTag, component, subComponent, action, message, contextInfo); 138 } 139 } 140 catch (exception) { 141 console.warn(exception); 142 } 143 } 144 145 /// End the timer and log required details for tracking 146 stop() { 147 try { 148 if (Helper.isTelemetryEnabled()) { 149 return this.blockPerfTracker.stop(); 150 } 151 } 152 catch (exception) { 153 console.warn(exception); 154 } 155 } 156}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.