Skip to content

Commit

Permalink
Merge pull request #17566 from jeclrsg/hpcc-29462-decode-html-chars-i…
Browse files Browse the repository at this point in the history
…n-logs

HPCC-29462 ECL Watch fix display of HTML entities in log messages
  • Loading branch information
GordonSmith authored Jul 13, 2023
2 parents 4a0099b + cbedc48 commit 1210cb5
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions esp/src/src-react/hooks/logging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import toast from "react-hot-toast";
import { isExceptions } from "@hpcc-js/comms";
import { Dispatch, Level, logger as utilLogger, scopedLogger, Writer, CallbackFunction, Message } from "@hpcc-js/util";
import { CustomToaster } from "../components/controls/CustomToaster";
import * as Utility from "src/Utility";

const logger = scopedLogger("../util/logging.ts");

Expand Down Expand Up @@ -69,13 +70,16 @@ export class ECLWatchLogger implements Writer {
rawWrite(dateTime: string, level: Level, id: string, _msg: string | object): void {
if (isExceptions(_msg)) {
_msg.Exception?.forEach(ex => {
this.doWrite(dateTime, level, id, `${ex.Code}: ${ex.Message}`);
const msg = Utility.decodeHTML(ex.Message);
this.doWrite(dateTime, level, id, `${ex.Code}: ${msg}`);
});
} else if (_msg instanceof Error) {
this.doWrite(dateTime, level, id, _msg.message);
} else if (typeof _msg !== "string") {
this.doWrite(dateTime, level, id, JSON.stringify(_msg, undefined, 2));
} else if (typeof _msg === "string") {
} else {
if (_msg instanceof Error) {
_msg = _msg.message;
} else if (typeof _msg !== "string") {
_msg = JSON.stringify(_msg, undefined, 2);
}
_msg = Utility.decodeHTML(_msg);
this.doWrite(dateTime, level, id, _msg);
}
}
Expand Down

0 comments on commit 1210cb5

Please sign in to comment.