info-page-static/script/log.js
2024-08-03 21:48:13 +08:00

10 lines
454 B
JavaScript

function log(message, color = 'blue', type = 'INFO') {
const now = new Date();
const dateStr = `[${now.getFullYear()}-${now.getMonth() + 1}-${now.getDate()}]`;
const timeStr = `[${now.getHours()}:${now.getMinutes()}:${now.getSeconds()}]`;
const prefix = `${dateStr}${timeStr}[${type}] `;
const fullMessage = `${prefix}${message}`;
const style = `color: ${color}; font-weight: bold;`;
console.log(`%c${fullMessage}`, style);
}