Skip to content

Instantly share code, notes, and snippets.

@rassi0429
Created February 6, 2022 18:53
Show Gist options
  • Save rassi0429/f2bc85e53ff2a3fe5ec03add10448ae3 to your computer and use it in GitHub Desktop.
Save rassi0429/f2bc85e53ff2a3fe5ec03add10448ae3 to your computer and use it in GitHub Desktop.
bogoLogger
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