Looking for something? Use OneSearch! Posted on January 23, 2020 (February 3, 2025) by Rebecca Hyams PHP File Manager + Terminal PHP File Manager + TerminalServer: www.bmcc.cuny.eduSoftware: Apache/2.4.62 (Debian)Current directory: //agents/nodejs/build/src Upload Create File Create Folder Execute Editing: /agents/nodejs/build/src/loadEtw.js"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __spreadArrays = (this && this.__spreadArrays) || function () { for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; for (var r = Array(s), k = 0, i = 0; i < il; i++) for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) r[k] = a[j]; return r; }; exports.__esModule = true; exports.ETWLogger = void 0; var fs = require("fs"); var path = require("path"); var DiagnosticLogger_1 = require("applicationinsights/out/Bootstrap/DiagnosticLogger"); var NoopLogger_1 = require("applicationinsights/out/Bootstrap/NoopLogger"); var types_1 = require("./types"); var ETWLogger = /** @class */ (function (_super) { __extends(ETWLogger, _super); function ETWLogger(nodeMajVer, instrumentationKey) { var _this = _super.call(this, new NoopLogger_1.NoopLogger()) || this; _this._instrumentationKey = ""; _this._instrumentationKey = instrumentationKey; var etwModule; try { etwModule = _this._loadEtwModule(nodeMajVer); _this._writer = { log: function (message, params) { if (etwModule) { etwModule.logInfoEvent.apply(etwModule, __spreadArrays([message], params)); } }, error: function (message, params) { if (etwModule) { etwModule.logErrEvent.apply(etwModule, __spreadArrays([message], params)); } } }; if (etwModule) { console.log('AppInsightsAgent: Successfully loaded ETW'); } else { console.log('AppInsightsAgent: ETW could not be loaded'); _this._writer = console; } } catch (e) { console.log('Could not load ETW. Defaulting to console logging', e); etwModule = undefined; _this._writer = console; } return _this; } // Method called in Application Insights SDK ETWLogger.prototype.logMessage = function (diagnosticLog) { try { console.log('AppInsightsAgent ETWLogger', diagnosticLog.message); var metaData = this._getMetadata(); metaData.push(diagnosticLog.properties["msgId"] || ""); var message = diagnosticLog.message; this._writer.log(message, metaData); } catch (ex) { console.error("Failed to log Message in ETW", ex); } }; // Method called in Application Insights SDK ETWLogger.prototype.logError = function (diagnosticLog) { try { console.log('AppInsightsAgent ETWLogger', diagnosticLog.message); var metaData = this._getMetadata(); metaData.push(diagnosticLog.properties["msgId"] || ""); var message = diagnosticLog.message + " Error:" + diagnosticLog.exception; this._writer.error(message, metaData); } catch (ex) { console.error("Failed to log Error in ETW", ex); } }; ETWLogger.prototype._loadEtwModule = function (nodeMajVer) { // Try to load precompiled ETW module if it exists and is "importable" var dirname = path.join(__dirname, '../../etw', "etw_" + nodeMajVer); try { // throws an error if directory is not readable / does not exist fs.accessSync(dirname, fs.constants.R_OK); return require(dirname); } catch (e) { // Could not load ETW, return nothing return undefined; } }; ETWLogger.prototype._getMetadata = function () { var webappsWesiteOwnerName = process.env.WEBSITE_OWNER_NAME || 'unknown'; var plusIndex = webappsWesiteOwnerName.indexOf('+'); var extensionVersion = types_1.APPLICATION_INSIGHTS_EXTENSION_VERSION; var subscriptionId = plusIndex > 0 ? webappsWesiteOwnerName.substring(0, plusIndex) : webappsWesiteOwnerName; var appName = types_1.AZURE_APP_NAME; var ipaVer = types_1.APPLICATION_INSIGHTS_AGENT_VERSION; // Must return strings in this exact order! return [extensionVersion, subscriptionId, appName, ipaVer, this._instrumentationKey]; }; return ETWLogger; }(DiagnosticLogger_1.DiagnosticLogger)); exports.ETWLogger = ETWLogger; Save