Skip to content

Commit

Permalink
[Change] #34, no further need for test logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Type-Style committed Mar 13, 2024
1 parent 32c9884 commit eb51ec8
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/scripts/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,16 @@ if (!fs.existsSync(dirPath)) {
fs.mkdirSync(dirPath, { recursive: true });
}

// const logPath = path.resolve(__dirname, '../httpdocs/log', 'start.txt');
const date = new Date().toLocaleString('de-DE', { hour12: false });

export default {
log: (message: string | JSON, showDateInConsole: boolean = false, showLogInTest = false) => {
log: (message: string | JSON, showDateInConsole: boolean = false) => {
message = JSON.stringify(message);
fs.appendFileSync(logPath, `${date} \t|\t ${message} \n`);
if (showDateInConsole) {
message = `${chalk.dim(date + ":")} ${message}`;
}
if (process.env.NODE_ENV == "development" || showLogInTest && process.env.NODE_ENV == "test") {
if (process.env.NODE_ENV != "production") {
console.log(message);
}
},
Expand All @@ -46,7 +45,7 @@ export default {
content = content.replace(prefix[0], chalk.red(prefix[0]));
}
}
console.error(content); // log string right away or processed Object
console.error(content);

}
}

0 comments on commit eb51ec8

Please sign in to comment.