mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-20 14:39:06 +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');
|
console.log('\n');
|
||||||
consoleHighlight(`Starting Ontime version ${ONTIME_VERSION}`);
|
consoleHighlight(`Starting Ontime version ${ONTIME_VERSION}`);
|
||||||
|
|
||||||
if (!isProduction) {
|
const canLog = isProduction;
|
||||||
|
if (!canLog) {
|
||||||
console.log(`Ontime running in ${environment} environment`);
|
console.log(`Ontime running in ${environment} environment`);
|
||||||
console.log(`Ontime directory at ${srcDirectory} `);
|
console.log(`Ontime directory at ${srcDirectory} `);
|
||||||
console.log(`Ontime database at ${resolveDbPath}`);
|
console.log(`Ontime database at ${resolveDbPath}`);
|
||||||
@@ -59,7 +60,7 @@ if (!isProduction) {
|
|||||||
// Create express APP
|
// Create express APP
|
||||||
const app = express();
|
const app = express();
|
||||||
if (process.env.NODE_ENV === 'development') {
|
if (process.env.NODE_ENV === 'development') {
|
||||||
// log more serever timings
|
// log server timings to requests
|
||||||
app.use(serverTiming());
|
app.use(serverTiming());
|
||||||
}
|
}
|
||||||
app.disable('x-powered-by');
|
app.disable('x-powered-by');
|
||||||
|
|||||||
@@ -9,10 +9,12 @@ import { consoleSubdued, consoleRed } from '../utils/console.js';
|
|||||||
class Logger {
|
class Logger {
|
||||||
private queue: Log[];
|
private queue: Log[];
|
||||||
private escalateErrorFn: (error: string) => void | null;
|
private escalateErrorFn: (error: string) => void | null;
|
||||||
|
private canLog = false;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.queue = [];
|
this.queue = [];
|
||||||
this.escalateErrorFn = null;
|
this.escalateErrorFn = null;
|
||||||
|
this.canLog = !isProduction;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -43,7 +45,7 @@ class Logger {
|
|||||||
* @param log
|
* @param log
|
||||||
*/
|
*/
|
||||||
private _push(log: Log) {
|
private _push(log: Log) {
|
||||||
if (!isProduction || log.level === LogLevel.Severe) {
|
if (this.canLog || log.level === LogLevel.Severe) {
|
||||||
if (log.level === LogLevel.Severe) {
|
if (log.level === LogLevel.Severe) {
|
||||||
consoleRed(`[${log.level}] \t ${log.origin} \t ${log.text}`);
|
consoleRed(`[${log.level}] \t ${log.origin} \t ${log.text}`);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user