Skip to content

Commit

Permalink
Fix issue with Diagnosticlogger errors logging (#955)
Browse files Browse the repository at this point in the history
  • Loading branch information
hectorhdzg authored Apr 26, 2022
1 parent 831807d commit 491aea2
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions Bootstrap/DiagnosticLogger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as DataModel from "./DataModel";
import { FileWriter } from "./FileWriter";
import { homedir } from "./Helpers/FileHelpers";
import { APPLICATION_INSIGHTS_SDK_VERSION } from "../Declarations/Constants";
import Util = require("../Library/Util");

export class DiagnosticLogger {
public static readonly DEFAULT_FILE_NAME: string = "application-insights-extension.log";
Expand All @@ -29,10 +30,7 @@ export class DiagnosticLogger {
DiagnosticLogger.DefaultEnvelope.properties.ikey = instrumentationKey;
}

logMessage(message: DataModel.DiagnosticLog | string, cb?: (err: Error) => void) {
if (typeof cb === "function" && this._writer instanceof FileWriter) {
this._writer.callback = cb;
}
logMessage(message: DataModel.DiagnosticLog | string) {
if (typeof message === "string") {
const diagnosticMessage: DataModel.DiagnosticLog = {
...DiagnosticLogger.DefaultEnvelope,
Expand All @@ -50,9 +48,9 @@ export class DiagnosticLogger {
}
}

logError(message: DataModel.DiagnosticLog | string, cb?: (err: Error) => void) {
if (typeof cb === "function" && this._writer instanceof FileWriter) {
this._writer.callback = cb;
logError(message: DataModel.DiagnosticLog | string, err?: Error) {
if (err) {
message += ` ${Util.dumpObj(err)}`;
}
if (typeof message === "string") {
const diagnosticMessage: DataModel.DiagnosticLog = {
Expand Down

0 comments on commit 491aea2

Please sign in to comment.