Created
February 6, 2022 18:53
-
-
Save rassi0429/f2bc85e53ff2a3fe5ec03add10448ae3 to your computer and use it in GitHub Desktop.
bogoLogger
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function info(msg, caller = null) { | |
console.log(`[INFO]${getTimeText()}${caller ? `[${caller}]` : ""} ${msg}`) | |
} | |
function error(msg, caller = null) { | |
console.log(`[EROR]${getTimeText()}${caller ? `[${caller}]` : ""} ${msg}`) | |
} | |
function getTimeText() { | |
const now = new Date() | |
const date = `[${now.getFullYear()}/${z(now.getMonth())}/${z(now.getDay())}` | |
const time = ` ${z(now.getHours())}:${z(now.getMinutes())}:${z(now.getSeconds())}]` | |
return date + time | |
} | |
function z(str) { | |
return ("0" + str).slice(-2) | |
} | |
module.exports = {info, error} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment