From 0a2cb47b0675a027297ccec0726b388b63d32b2e Mon Sep 17 00:00:00 2001 From: Killer Boss Original <73131550+killerbossoriginal@users.noreply.github.com> Date: Tue, 24 Jan 2023 17:04:50 +0100 Subject: [PATCH] Add debug Level in cout --- index.js | 25 +++++++++++++++++++------ package.json | 2 +- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index 5d52b5d..6d8a453 100644 --- a/index.js +++ b/index.js @@ -45,11 +45,24 @@ function cin (question, hide) { }) }; -async function cout (string) { - var time = getTime(); - string = `[${time.year}.${time.month}.${time.day}-${time.hours}:${time.minutes}:${time.seconds}] | ${String(string)}` - console.log(string); - log(string); -}; +class createCout { + constructor (debugLevel, logs) { + this.debug = debugLevel; + this.logs = logs; + } + + cout (string, debugLevel) { + if (!debugLevel) debugLevel = 0; + var time = getTime(); + + if (this.debug >= debugLevel) { + console.log(`[${time.year}.${time.month}.${time.day}-${time.hours}:${time.minutes}:${time.seconds}] | ${String(string)}`); + if (this.logs) { + log(string); + } + } + return; + }; +} module.exports = { cin, cout, createLog, log }; diff --git a/package.json b/package.json index 666f569..20dde5c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@thundernetworkrad/std", - "version": "2022.12.29", + "version": "2023.01.24", "description": "Standard module for javascript", "main": "index.js", "scripts": {