chore: prepare log levels

This commit is contained in:
Carlos Valente
2024-06-10 09:55:43 +02:00
committed by Carlos Valente
parent e9f806b88a
commit 86b4ddadb5
2 changed files with 6 additions and 3 deletions
+3 -2
View File
@@ -50,7 +50,8 @@ import { getNetworkInterfaces } from './utils/networkInterfaces.js';
console.log('\n');
consoleHighlight(`Starting Ontime version ${ONTIME_VERSION}`);
if (!isProduction) {
const canLog = isProduction;
if (!canLog) {
console.log(`Ontime running in ${environment} environment`);
console.log(`Ontime directory at ${srcDirectory} `);
console.log(`Ontime database at ${resolveDbPath}`);
@@ -59,7 +60,7 @@ if (!isProduction) {
// Create express APP
const app = express();
if (process.env.NODE_ENV === 'development') {
// log more serever timings
// log server timings to requests
app.use(serverTiming());
}
app.disable('x-powered-by');
+3 -1
View File
@@ -9,10 +9,12 @@ import { consoleSubdued, consoleRed } from '../utils/console.js';
class Logger {
private queue: Log[];
private escalateErrorFn: (error: string) => void | null;
private canLog = false;
constructor() {
this.queue = [];
this.escalateErrorFn = null;
this.canLog = !isProduction;
}
/**
@@ -43,7 +45,7 @@ class Logger {
* @param log
*/
private _push(log: Log) {
if (!isProduction || log.level === LogLevel.Severe) {
if (this.canLog || log.level === LogLevel.Severe) {
if (log.level === LogLevel.Severe) {
consoleRed(`[${log.level}] \t ${log.origin} \t ${log.text}`);
} else {