Files
Microsoft-Rewards-Script/src/util/Logger.ts
TheNetsky 3b15fe19a7 1.2.5
2023-11-04 16:21:56 +01:00

26 lines
719 B
TypeScript

import { Webhook } from './Webhook'
export function log(title: string, message: string, type?: 'log' | 'warn' | 'error') {
const currentTime = new Date().toLocaleString()
let str = ''
switch (type) {
case 'warn':
str = `[${currentTime}] [PID: ${process.pid}] [WARN] [${title}] ${message}`
console.warn(str)
break
case 'error':
str = `[${currentTime}] [PID: ${process.pid}] [ERROR] [${title}] ${message}`
console.error(str)
break
default:
str = `[${currentTime}] [PID: ${process.pid}] [LOG] [${title}] ${message}`
console.log(str)
break
}
if (str) Webhook(str)
}