17 lines
872 B
JavaScript
17 lines
872 B
JavaScript
/*───────────────────────────────────────────────────────────────*/
|
|
/* 🖨️ Logger */
|
|
/*───────────────────────────────────────────────────────────────*/
|
|
import dayjs from 'dayjs';
|
|
import utc from 'dayjs/plugin/utc.js';
|
|
import { config } from './config.js';
|
|
|
|
dayjs.extend(utc);
|
|
|
|
export function log(level, ...args) {
|
|
const levels = ['debug', 'info', 'warn', 'error'];
|
|
if (levels.indexOf(level) >= levels.indexOf(config.LOG_LEVEL)) {
|
|
console[level === 'debug' ? 'log' : level](
|
|
`[${dayjs().utc().format()}]`, level.toUpperCase(), ...args
|
|
);
|
|
}
|
|
} |