Compare commits

..

2 Commits

Author SHA1 Message Date
cbf56b54c1 Fix: info log return in Log module 2024-05-02 02:08:08 +02:00
1f121a8565 Added: error log in Log module 2024-05-02 00:10:39 +02:00

View File

@ -3,21 +3,32 @@ import fs from 'fs'
import path from 'path'
export default class Log {
public static info(code: number, message: string, data?:any): void {
public static info(code: number, message: string, data?: any): object {
if (!data) {
data = ""
data = ''
}
console.log(colors.bgGreen.black(` ${code} `) + colors.green.bgBlack(` ${message} `) + data)
//this.writeLog('info', code, message, data)
return {
code: code,
message: message,
data: data
}
}
public static error(code: number, message: string, data?:any): void {
public static error(code: number, message: string, data?: any): object {
if (!data) {
data = ""
data = ''
}
console.log(colors.bgRed.black(` ${code} `) + colors.red.bgBlack(` ${message} `) + data)
//this.writeLog('error', code, message, data)
return {
code: code,
message: message,
data: data
}
}
private static writeLog(level: string, code: number, message: string, data?: any): void {
if (data) {
@ -25,11 +36,10 @@ export default class Log {
}
try {
throw Error("nevim")
throw Error('nevim')
} catch (error) {
this.error(500, 'Error while writing to log file', error)
return
}
}
}