veko
Version:
đ Ultra-modern Node.js framework with hot reload, plugins, authentication, and advanced security features
97 lines (92 loc) âĸ 2.76 kB
JavaScript
const colors = {
reset: '\x1b[0m',
bright: '\x1b[1m',
dim: '\x1b[2m',
red: '\x1b[31m',
green: '\x1b[32m',
yellow: '\x1b[33m',
blue: '\x1b[34m',
magenta: '\x1b[35m',
cyan: '\x1b[36m',
white: '\x1b[37m',
gray: '\x1b[90m',
bgRed: '\x1b[41m',
bgGreen: '\x1b[42m',
bgYellow: '\x1b[43m',
bgBlue: '\x1b[44m',
bgMagenta: '\x1b[45m',
bgCyan: '\x1b[46m'
};
class Logger {
log(type, message, details = '') {
const timestamp = new Date().toLocaleTimeString('en-US');
const prefix = `${colors.gray}[${timestamp}]${colors.reset}`;
const logStyles = {
success: {
badge: `${colors.bgGreen}${colors.white} ⨠`,
text: `${colors.green}${colors.bright}`,
icon: 'đ'
},
error: {
badge: `${colors.bgRed}${colors.white} đĨ `,
text: `${colors.red}${colors.bright}`,
icon: 'â'
},
warning: {
badge: `${colors.bgYellow}${colors.white} ⥠`,
text: `${colors.yellow}${colors.bright}`,
icon: 'â ī¸'
},
info: {
badge: `${colors.bgBlue}${colors.white} đ `,
text: `${colors.blue}${colors.bright}`,
icon: 'âšī¸'
},
server: {
badge: `${colors.bgMagenta}${colors.white} đ `,
text: `${colors.magenta}${colors.bright}`,
icon: 'đ'
},
route: {
badge: `${colors.bgCyan}${colors.white} đ `,
text: `${colors.cyan}${colors.bright}`,
icon: 'đ'
},
dev: {
badge: `${colors.bgBlue}${colors.white} đ ī¸ `,
text: `${colors.blue}${colors.bright}`,
icon: 'âī¸'
},
file: {
badge: `${colors.bgGreen}${colors.white} đ `,
text: `${colors.green}${colors.bright}`,
icon: 'đ'
},
reload: {
badge: `${colors.bgYellow}${colors.white} đ `,
text: `${colors.yellow}${colors.bright}`,
icon: 'đ'
},
create: {
badge: `${colors.bgGreen}${colors.white} â `,
text: `${colors.green}${colors.bright}`,
icon: 'â
'
},
delete: {
badge: `${colors.bgRed}${colors.white} đī¸ `,
text: `${colors.red}${colors.bright}`,
icon: 'đī¸'
},
install: {
badge: `${colors.bgMagenta}${colors.white} đĻ `,
text: `${colors.magenta}${colors.bright}`,
icon: 'đĻ'
}
};
const style = logStyles[type] || logStyles.info;
console.log(
`${prefix} ${style.badge}${colors.reset} ${style.text}${message}${colors.reset} ${colors.dim}${details}${colors.reset}`
);
}
}
module.exports = Logger;