From 1a0f8e6b16fd79d8876ee7c86d9522332512a94e Mon Sep 17 00:00:00 2001 From: Zak Timson Date: Mon, 14 Mar 2022 01:54:30 +0000 Subject: [PATCH] Simplified logger.js --- scripts/lib/logger.js | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/scripts/lib/logger.js b/scripts/lib/logger.js index e9430b6..328e063 100644 --- a/scripts/lib/logger.js +++ b/scripts/lib/logger.js @@ -1,18 +1,16 @@ export class Logger { - historyLen = 17; + historyLen = 19; history = []; /** * Create a nicer log with a banner. * @param ns {NS} - BitBurner API - * @param titleFn {Function} - Function to generate title - * @param extraFns {Function[]} - Extra info to put in the header + * @param lineFns {Function[]} - Functions to generate a line (Seperated by a linebreak) */ - constructor(ns, titleFn, extraFns = []) { + constructor(ns, lineFns = []) { this.ns = ns; - this.title = titleFn; - this.extra = extraFns; - this.historyLen -= extraFns.length * 2; + this.fns = lineFns; + this.historyLen -= fns.length * 2; this.history = Array(this.historyLen).fill(''); } @@ -28,10 +26,8 @@ export class Logger { */ header() { this.lineBreak(); - this.ns.print(this.title()); - this.lineBreak(); - this.extra.forEach(extra => { - this.ns.print(extra()); + this.fns.forEach(fn => { + this.ns.print(fn()); this.lineBreak(); }); }