Updated logger and logs path

This commit is contained in:
Jonathan Barrow 2023-04-22 17:11:23 -04:00
parent 442c20ed67
commit c13383812e
No known key found for this signature in database
GPG Key ID: E86E9FE9049C741F
2 changed files with 11 additions and 11 deletions

2
.gitignore vendored
View File

@ -131,5 +131,5 @@ dist
# custom
certs
src/logs
logs
dist

View File

@ -3,7 +3,7 @@ import colors from 'colors';
colors.enable();
const root = __dirname;
const root: string = process.env.PN_MIIVERSE_API_LOGGER_PATH ? process.env.PN_MIIVERSE_API_LOGGER_PATH : `${__dirname}/..`;
fs.ensureDirSync(`${root}/logs`);
const streams = {
@ -12,34 +12,34 @@ const streams = {
error: fs.createWriteStream(`${root}/logs/error.log`),
warn: fs.createWriteStream(`${root}/logs/warn.log`),
info: fs.createWriteStream(`${root}/logs/info.log`)
};
} as const;
export function LOG_SUCCESS(input) {
const time = new Date();
export function LOG_SUCCESS(input: string): void {
const time: Date = new Date();
input = `[${time.getHours()}:${time.getMinutes()}:${time.getSeconds()}] [SUCCESS]: ${input}`;
streams.success.write(`${input}\n`);
console.log(`${input}`.green.bold);
}
export function LOG_ERROR(input) {
const time = new Date();
export function LOG_ERROR(input: string): void {
const time: Date = new Date();
input = `[${time.getHours()}:${time.getMinutes()}:${time.getSeconds()}] [ERROR]: ${input}`;
streams.error.write(`${input}\n`);
console.log(`${input}`.red.bold);
}
export function LOG_WARN(input) {
const time = new Date();
export function LOG_WARN(input: string): void {
const time: Date = new Date();
input = `[${time.getHours()}:${time.getMinutes()}:${time.getSeconds()}] [WARN]: ${input}`;
streams.warn.write(`${input}\n`);
console.log(`${input}`.yellow.bold);
}
export function LOG_INFO(input) {
const time = new Date();
export function LOG_INFO(input: string): void {
const time: Date = new Date();
input = `[${time.getHours()}:${time.getMinutes()}:${time.getSeconds()}] [INFO]: ${input}`;
streams.info.write(`${input}\n`);