Skip to content

Commit

Permalink
Merge pull request #259 from serguun42/metrics-and-traces
Browse files Browse the repository at this point in the history
Update logs storing into MongoDB, add more checks to Panel page
  • Loading branch information
serguun42 authored Dec 12, 2023
2 parents c8f34b8 + 7626418 commit ace8b66
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion notifier/interfaces/mongo.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const mongoDispatcher = new MongoDispatcher(DATABASE_NAME);
export default function LogToMongo(loggingPayload) {
mongoDispatcher
.callDB()
.then((db) => db.collection("logs").insertOne({ loggingPayload, date: new Date() }))
.then((db) => db.collection("logs").insertOne({ ...loggingPayload, date: new Date() }))
.catch((e) => {
LogToConsole({
isError: true,
Expand Down
25 changes: 13 additions & 12 deletions panel/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ <h1 class="panel__header">MSS Params</h1>
/** @param {{ isError: boolean, args: string[], tag: string, date?: string }[]} logs */ (logs) => {
logsTableBody.innerHTML = null;

logs.forEach((log, index) => {
logs.filter(Boolean).forEach((log, index) => {
const row = document.createElement("tr");

const indexCell = document.createElement("td");
Expand All @@ -394,18 +394,19 @@ <h1 class="panel__header">MSS Params</h1>

const messages = document.createElement("td");
messages.classList.add("panel__table__logs-messages");
log.args.forEach((arg) => {
const pre = document.createElement("pre");
if (typeof arg === "string") pre.innerText = arg;
else {
try {
pre.innerText = JSON.stringify(arg, null, 2);
} catch (_) {
pre.innerText = `${arg}`;
if (Array.isArray(log.args))
log.args.forEach((arg) => {
const pre = document.createElement("pre");
if (typeof arg === "string") pre.innerText = arg;
else {
try {
pre.innerText = JSON.stringify(arg, null, 2);
} catch (_) {
pre.innerText = `${arg}`;
}
}
}
messages.appendChild(pre);
});
messages.appendChild(pre);
});

const tag = document.createElement("td");
tag.innerText = log.tag;
Expand Down

0 comments on commit ace8b66

Please sign in to comment.