mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-12 02:43:50 +00:00
style: organise console levels and semantics
This commit is contained in:
committed by
Carlos Valente
parent
4f672670ed
commit
e9f806b88a
@@ -20,7 +20,7 @@ import {
|
||||
clearUploadfolder,
|
||||
} from './setup/index.js';
|
||||
import { ONTIME_VERSION } from './ONTIME_VERSION.js';
|
||||
import { consoleGreen } from './utils/console.js';
|
||||
import { consoleSuccess, consoleHighlight } from './utils/console.js';
|
||||
|
||||
// Import Routers
|
||||
import { appRouter } from './api-data/index.js';
|
||||
@@ -47,7 +47,8 @@ import { initRundown } from './services/rundown-service/RundownService.js';
|
||||
import { generateCrashReport } from './utils/generateCrashReport.js';
|
||||
import { getNetworkInterfaces } from './utils/networkInterfaces.js';
|
||||
|
||||
console.log(`Starting Ontime version ${ONTIME_VERSION}`);
|
||||
console.log('\n');
|
||||
consoleHighlight(`Starting Ontime version ${ONTIME_VERSION}`);
|
||||
|
||||
if (!isProduction) {
|
||||
console.log(`Ontime running in ${environment} environment`);
|
||||
@@ -205,8 +206,9 @@ export const startServer = async (
|
||||
|
||||
expressServer.listen(serverPort, '0.0.0.0', () => {
|
||||
const nif = getNetworkInterfaces();
|
||||
consoleSuccess(`Local: http://localhost:${serverPort}/editor`);
|
||||
for (const key of Object.keys(nif)) {
|
||||
consoleGreen(`Ontime running on: http://${nif[key].address}:${serverPort}`);
|
||||
consoleSuccess(`Network: http://${nif[key].address}:${serverPort}/editor`);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -252,7 +254,7 @@ export const startIntegrations = async (config?: { osc: OSCSettings; http: HttpS
|
||||
* @return {Promise<void>}
|
||||
*/
|
||||
export const shutdown = async (exitCode = 0) => {
|
||||
console.log(`Ontime shutting down with code ${exitCode}`);
|
||||
consoleHighlight(`Ontime shutting down with code ${exitCode}`);
|
||||
|
||||
// clear the restore file if it was a normal exit
|
||||
// 0 means it was a SIGNAL
|
||||
@@ -270,7 +272,7 @@ export const shutdown = async (exitCode = 0) => {
|
||||
process.exit(exitCode);
|
||||
};
|
||||
|
||||
process.on('exit', (code) => console.log(`Ontime shutdown with code: ${code}`));
|
||||
process.on('exit', (code) => consoleHighlight(`Ontime shutdown with code: ${code}`));
|
||||
|
||||
process.on('unhandledRejection', async (error) => {
|
||||
generateCrashReport(error);
|
||||
|
||||
@@ -4,7 +4,7 @@ import { generateId, millisToString } from 'ontime-utils';
|
||||
import { clock } from '../services/Clock.js';
|
||||
import { isProduction } from '../setup/index.js';
|
||||
import { socket } from '../adapters/WebsocketAdapter.js';
|
||||
import { consoleRed } from '../utils/console.js';
|
||||
import { consoleSubdued, consoleRed } from '../utils/console.js';
|
||||
|
||||
class Logger {
|
||||
private queue: Log[];
|
||||
@@ -47,8 +47,7 @@ class Logger {
|
||||
if (log.level === LogLevel.Severe) {
|
||||
consoleRed(`[${log.level}] \t ${log.origin} \t ${log.text}`);
|
||||
} else {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`[${log.level}] \t ${log.origin} \t ${log.text}`);
|
||||
consoleSubdued(`[${log.level}] \t ${log.origin} \t ${log.text}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,16 +1,22 @@
|
||||
/* eslint-disable no-console */
|
||||
import { consoleHighlight, consoleRed } from './utils/console.js';
|
||||
import { initAssets, startIntegrations, startServer } from './app.js';
|
||||
|
||||
async function startOntime() {
|
||||
try {
|
||||
console.log('Request: Initialise assets...');
|
||||
console.log('\n');
|
||||
consoleHighlight('Request: Initialise assets...');
|
||||
await initAssets();
|
||||
console.log('Request: Start server...');
|
||||
|
||||
console.log('\n');
|
||||
consoleHighlight('Request: Start server...');
|
||||
await startServer();
|
||||
console.log('Request: Start integrations...');
|
||||
|
||||
console.log('\n');
|
||||
consoleHighlight('Request: Start integrations...');
|
||||
await startIntegrations();
|
||||
} catch (error) {
|
||||
console.log(`Request failed: ${error}`);
|
||||
consoleRed(`Request failed: ${error}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,13 +3,55 @@
|
||||
/**
|
||||
* Utility function to log messages in green
|
||||
*/
|
||||
export function consoleGreen(message: string) {
|
||||
console.log(`\x1b[32m${message}\x1b[0m`);
|
||||
export function consoleSuccess(message: string) {
|
||||
console.log(inGreen(message));
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility function to log messages in red
|
||||
*/
|
||||
export function consoleRed(message: string) {
|
||||
console.error(`\x1b[31m${message}\x1b[0m`);
|
||||
console.error(inRed(message));
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility function to log messages with dimmed appearance
|
||||
*/
|
||||
export function consoleHighlight(message: string) {
|
||||
console.log(inCyan(message));
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility function to log messages with dimmed appearance
|
||||
*/
|
||||
export function consoleSubdued(message: string) {
|
||||
console.log(inGray(message));
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility function for console, styles text in green
|
||||
*/
|
||||
function inGreen(message: string): string {
|
||||
return `\x1b[32m${message}\x1b[0m`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility function for console, styles text in red
|
||||
*/
|
||||
function inRed(message: string): string {
|
||||
return `\x1b[31m${message}\x1b[0m`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility function for console, styles text in cyan
|
||||
*/
|
||||
function inCyan(message: string): string {
|
||||
return `\x1b[96m${message}\x1b[0m`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility function for console, styles text in gray
|
||||
*/
|
||||
function inGray(message: string): string {
|
||||
return `\x1b[2m${message}\x1b[0m`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user