mirror of
https://github.com/PretendoNetwork/miiverse-api.git
synced 2026-04-25 07:36:49 -05:00
Updated logger and logs path
This commit is contained in:
parent
442c20ed67
commit
c13383812e
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -131,5 +131,5 @@ dist
|
|||
|
||||
# custom
|
||||
certs
|
||||
src/logs
|
||||
logs
|
||||
dist
|
||||
|
|
@ -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`);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user