From e935f5a383cc3aaa7b38a3c5067dd0d05da6073e Mon Sep 17 00:00:00 2001 From: Seweryn Kras Date: Wed, 8 Nov 2023 17:43:35 +0100 Subject: [PATCH] feat(logger): removed table from all loggers --- .../transferring-data/transfer-data-in-browser.html | 1 - .../examples/transferring-data/upload-json-in-browser.html | 1 - .../docs-examples/quickstarts/web-quickstart/requestor.mjs | 1 - .../tutorials/running-from-browser/index.html | 1 - examples/web/hello.html | 1 - examples/web/image.html | 1 - src/executor/executor.ts | 6 +++++- src/utils/logger/consoleLogger.ts | 1 - src/utils/logger/logger.ts | 7 ------- src/utils/logger/nullLogger.ts | 1 - src/utils/logger/pinoLogger.ts | 1 - 11 files changed, 5 insertions(+), 17 deletions(-) diff --git a/examples/docs-examples/examples/transferring-data/transfer-data-in-browser.html b/examples/docs-examples/examples/transferring-data/transfer-data-in-browser.html index d6c58d0e7..f9aebf4ad 100644 --- a/examples/docs-examples/examples/transferring-data/transfer-data-in-browser.html +++ b/examples/docs-examples/examples/transferring-data/transfer-data-in-browser.html @@ -93,7 +93,6 @@

Logs

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() { diff --git a/examples/docs-examples/examples/transferring-data/upload-json-in-browser.html b/examples/docs-examples/examples/transferring-data/upload-json-in-browser.html index 60745d8ab..55c61ebc4 100644 --- a/examples/docs-examples/examples/transferring-data/upload-json-in-browser.html +++ b/examples/docs-examples/examples/transferring-data/upload-json-in-browser.html @@ -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({ diff --git a/examples/docs-examples/quickstarts/web-quickstart/requestor.mjs b/examples/docs-examples/quickstarts/web-quickstart/requestor.mjs index 6ddeb382e..4ac4edde8 100644 --- a/examples/docs-examples/quickstarts/web-quickstart/requestor.mjs +++ b/examples/docs-examples/quickstarts/web-quickstart/requestor.mjs @@ -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() { diff --git a/examples/docs-examples/tutorials/running-from-browser/index.html b/examples/docs-examples/tutorials/running-from-browser/index.html index 0805a5f19..3b89925fa 100644 --- a/examples/docs-examples/tutorials/running-from-browser/index.html +++ b/examples/docs-examples/tutorials/running-from-browser/index.html @@ -60,7 +60,6 @@

Logs

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({ diff --git a/examples/web/hello.html b/examples/web/hello.html index 6907a06fd..ba412d982 100644 --- a/examples/web/hello.html +++ b/examples/web/hello.html @@ -80,7 +80,6 @@

Logs

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; diff --git a/examples/web/image.html b/examples/web/image.html index cfb83d823..ef2661791 100644 --- a/examples/web/image.html +++ b/examples/web/image.html @@ -104,7 +104,6 @@

Logs

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() { diff --git a/src/executor/executor.ts b/src/executor/executor.ts index e816f281e..1867a2dcf 100644 --- a/src/executor/executor.ts +++ b/src/executor/executor.ts @@ -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}`); } diff --git a/src/utils/logger/consoleLogger.ts b/src/utils/logger/consoleLogger.ts index c9240c0e6..3c74dcd33 100644 --- a/src/utils/logger/consoleLogger.ts +++ b/src/utils/logger/consoleLogger.ts @@ -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, }; } diff --git a/src/utils/logger/logger.ts b/src/utils/logger/logger.ts index 7d28030b6..cdc0b6842 100644 --- a/src/utils/logger/logger.ts +++ b/src/utils/logger/logger.ts @@ -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); } diff --git a/src/utils/logger/nullLogger.ts b/src/utils/logger/nullLogger.ts index c4f2f5c47..ebf7b7813 100644 --- a/src/utils/logger/nullLogger.ts +++ b/src/utils/logger/nullLogger.ts @@ -12,7 +12,6 @@ export function nullLogger(): Logger { log: nullFunc, warn: nullFunc, error: nullFunc, - table: nullFunc, setLevel: nullFunc, }; } diff --git a/src/utils/logger/pinoLogger.ts b/src/utils/logger/pinoLogger.ts index 5b0805e01..6bed6a3b3 100644 --- a/src/utils/logger/pinoLogger.ts +++ b/src/utils/logger/pinoLogger.ts @@ -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;