mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-06 16:03:52 +00:00
chore: prepare log levels
This commit is contained in:
committed by
Carlos Valente
parent
e9f806b88a
commit
86b4ddadb5
@@ -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');
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user