UNPKG

applicationinsights

Version:

Microsoft Application Insights module for Node.js

35 lines 1.39 kB
"use strict"; // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. Object.defineProperty(exports, "__esModule", { value: true }); exports.StatusLogger = void 0; const os = require("os"); const fileWriter_1 = require("./writers/fileWriter"); const types_1 = require("../types"); const types_2 = require("../../types"); class StatusLogger { constructor(instrumentationKey, agentLogger = console) { this._agentLogger = agentLogger; this._instrumentationKey = instrumentationKey; this._language = types_1.LOGGER_LANGUAGE; this._sdkVersion = types_2.APPLICATION_INSIGHTS_OPENTELEMETRY_VERSION; this._machineName = os.hostname(); this._processId = String(process.pid); } logStatus(status, cb) { this._addCommonProperties(status); if (typeof cb === "function" && this._agentLogger instanceof fileWriter_1.FileWriter) { this._agentLogger.callback = cb; } this._agentLogger.log(status); } _addCommonProperties(status) { status.AppType = this._language; status.MachineName = this._machineName; status.PID = this._processId; status.SdkVersion = this._sdkVersion; status.Ikey = this._instrumentationKey; } } exports.StatusLogger = StatusLogger; //# sourceMappingURL=statusLogger.js.map