Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JST-547: Remove console table #644

Merged
merged 1 commit into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ <h3>Logs</h3>
debug: (msg) => appendLog(`[${new Date().toISOString()}] [debug] ${msg}`),
error: (msg) => appendLog(`[${new Date().toISOString()}] [error] ${msg}`),
info: (msg) => appendLog(`[${new Date().toISOString()}] [info] ${msg}`),
table: (msg) => appendLog(JSON.stringify(msg, null, "\t")),
};

async function run() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
debug: (msg) => 0, //appendLog(msg, 'debug'),
error: (msg) => appendLog(msg, "error"),
info: (msg) => appendLog(msg, "info"),
table: (msg) => appendLog(JSON.stringify(msg, null, "\t")),
};
async function run() {
const executor = await TaskExecutor.create({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const logger = {
debug: (msg) => appendLog(msg, "debug"),
error: (msg) => appendLog(msg, "error"),
info: (msg) => appendLog(msg, "info"),
table: (msg) => appendLog(JSON.stringify(msg, null, "\t")),
};

async function run() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ <h3>Logs</h3>
debug: (msg) => console.log(msg),
error: (msg) => appendLog(`[${new Date().toISOString()}] [error] ${msg}`),
info: (msg) => appendLog(`[${new Date().toISOString()}] [info] ${msg}`),
table: (msg) => appendLog(JSON.stringify(msg, null, "\t")),
};
async function run() {
const executor = await TaskExecutor.create({
Expand Down
1 change: 0 additions & 1 deletion examples/web/hello.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ <h3>Logs</h3>
debug: (msg) => appendLog(`[${new Date().toISOString()}] [debug] ${msg}`),
error: (msg) => appendLog(`[${new Date().toISOString()}] [error] ${msg}`),
info: (msg) => appendLog(`[${new Date().toISOString()}] [info] ${msg}`),
table: (msg) => appendLog(JSON.stringify(msg, null, "\t")),
};
async function run() {
const apiKey = document.getElementById("YAGNA_APPKEY").value;
Expand Down
1 change: 0 additions & 1 deletion examples/web/image.html
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ <h3>Logs</h3>
debug: (msg) => appendLog(`[${new Date().toISOString()}] [debug] ${msg}`),
error: (msg) => appendLog(`[${new Date().toISOString()}] [error] ${msg}`),
info: (msg) => appendLog(`[${new Date().toISOString()}] [info] ${msg}`),
table: (msg) => appendLog(JSON.stringify(msg, null, "\t")),
};

async function run() {
Expand Down
6 changes: 5 additions & 1 deletion src/executor/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,11 @@ export class TaskExecutor {
const providersCount = new Set(costsSummary.map((x) => x["Provider Name"])).size;
this.logger?.info(`Computation finished in ${duration}`);
this.logger?.info(`Negotiated ${costsSummary.length} agreements with ${providersCount} providers`);
if (costsSummary.length) this.logger?.table?.(costsSummary);
costsSummary.forEach((cost) => {
this.logger?.info(
`Agreement ${cost["Agreement"]} with ${cost["Provider Name"]} computed ${cost["Task Computed"]} task(s) for ${cost["Cost"]} GLM (${cost["Payment Status"]})`,
);
});
this.logger?.info(`Total Cost: ${costs.total} Total Paid: ${costs.paid}`);
}

Expand Down
1 change: 0 additions & 1 deletion src/utils/logger/consoleLogger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export function consoleLogger(): Logger {
log: (msg: string) => print("log", msg),
setLevel: (lvl: string) => (level = lvl),
warn: (msg) => print("warn", msg),
table: (obj) => console.table(obj),
level,
};
}
7 changes: 0 additions & 7 deletions src/utils/logger/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,4 @@ export interface Logger {
warn(msg);
error(msg);
debug(msg);

/**
* Produce a table representation of the supplied data.
* This is currently used to display cost summary.
* @param object
*/
table?(object);
}
1 change: 0 additions & 1 deletion src/utils/logger/nullLogger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export function nullLogger(): Logger {
log: nullFunc,
warn: nullFunc,
error: nullFunc,
table: nullFunc,
setLevel: nullFunc,
};
}
1 change: 0 additions & 1 deletion src/utils/logger/pinoLogger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export function pinoLogger(optionsOrStream?: pino.LoggerOptions | pino.Destinati
log: (msg) => logger.info(msg),
warn: (msg) => logger.warn(msg),
error: (msg) => logger.error(msg),
table: (object) => console.table(object),
setLevel: function (level: string) {
logger.level = level;
this.level = level as LogLevel;
Expand Down
Loading