Skip to content

Commit

Permalink
feat(logger): removed table from all loggers
Browse files Browse the repository at this point in the history
  • Loading branch information
SewerynKras committed Nov 8, 2023
1 parent 2d598a3 commit e935f5a
Show file tree
Hide file tree
Showing 11 changed files with 5 additions and 17 deletions.
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

0 comments on commit e935f5a

Please sign in to comment.