bugly.js
Version:
Bugly.js helps beginners and time-pressed people!
64 lines (48 loc) • 1.51 kB
JavaScript
// @ts-check
const color = {
RESET: "\x1b[0m",
GRAY: "\x1b[90m",
RED: "\x1b[31m",
GREEN: "\x1b[32m",
YELLOW: "\x1b[33m",
BLUE: "\x1b[34m",
};
const styles = {
bold: "\u001b[1m",
italic: "\u001b[3m",
underline: "\u001b[4m",
};
function log({ text, status, statusColor }) {
const date = new Date();
const hour = String(date.getHours()).padStart(2, '0');
const min = String(date.getMinutes()).padStart(2, '0');
const sec = String(date.getSeconds()).padStart(2, '0');
let fullTime = `${hour}:${min}:${sec}`;
console.log(`${color.GRAY}[${fullTime}] ${statusColor} [${status}]: ${color.RESET} ${text}`);
}
class Log {
constructor() {
this.underline = function (text) {
return `${styles.underline}${text}${color.RESET}`;
};
this.italic = function (text) {
return `${styles.italic}${text}${color.RESET}`;
};
this.bold = function (text) {
return `${styles.bold}${text}${color.RESET}`;
};
};
info(text) {
log({ text, status: "INFO", statusColor: color.BLUE });
}
succes(text) {
log({ text, status: "SUCCESS", statusColor: color.GREEN });
};
warning(text) {
log({ text, status: "WARNING", statusColor: color.YELLOW });
};
error(text) {
log({ text, status: "ERROR", statusColor: color.RED });
};
};
module.exports = { Log };