mirror of
https://github.com/cpvalente/ontime.git
synced 2026-09-05 22:39:11 +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,
|
clearUploadfolder,
|
||||||
} from './setup/index.js';
|
} from './setup/index.js';
|
||||||
import { ONTIME_VERSION } from './ONTIME_VERSION.js';
|
import { ONTIME_VERSION } from './ONTIME_VERSION.js';
|
||||||
import { consoleGreen } from './utils/console.js';
|
import { consoleSuccess, consoleHighlight } from './utils/console.js';
|
||||||
|
|
||||||
// Import Routers
|
// Import Routers
|
||||||
import { appRouter } from './api-data/index.js';
|
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 { generateCrashReport } from './utils/generateCrashReport.js';
|
||||||
import { getNetworkInterfaces } from './utils/networkInterfaces.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) {
|
if (!isProduction) {
|
||||||
console.log(`Ontime running in ${environment} environment`);
|
console.log(`Ontime running in ${environment} environment`);
|
||||||
@@ -205,8 +206,9 @@ export const startServer = async (
|
|||||||
|
|
||||||
expressServer.listen(serverPort, '0.0.0.0', () => {
|
expressServer.listen(serverPort, '0.0.0.0', () => {
|
||||||
const nif = getNetworkInterfaces();
|
const nif = getNetworkInterfaces();
|
||||||
|
consoleSuccess(`Local: http://localhost:${serverPort}/editor`);
|
||||||
for (const key of Object.keys(nif)) {
|
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>}
|
* @return {Promise<void>}
|
||||||
*/
|
*/
|
||||||
export const shutdown = async (exitCode = 0) => {
|
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
|
// clear the restore file if it was a normal exit
|
||||||
// 0 means it was a SIGNAL
|
// 0 means it was a SIGNAL
|
||||||
@@ -270,7 +272,7 @@ export const shutdown = async (exitCode = 0) => {
|
|||||||
process.exit(exitCode);
|
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) => {
|
process.on('unhandledRejection', async (error) => {
|
||||||
generateCrashReport(error);
|
generateCrashReport(error);
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { generateId, millisToString } from 'ontime-utils';
|
|||||||
import { clock } from '../services/Clock.js';
|
import { clock } from '../services/Clock.js';
|
||||||
import { isProduction } from '../setup/index.js';
|
import { isProduction } from '../setup/index.js';
|
||||||
import { socket } from '../adapters/WebsocketAdapter.js';
|
import { socket } from '../adapters/WebsocketAdapter.js';
|
||||||
import { consoleRed } from '../utils/console.js';
|
import { consoleSubdued, consoleRed } from '../utils/console.js';
|
||||||
|
|
||||||
class Logger {
|
class Logger {
|
||||||
private queue: Log[];
|
private queue: Log[];
|
||||||
@@ -47,8 +47,7 @@ class Logger {
|
|||||||
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 {
|
||||||
// eslint-disable-next-line no-console
|
consoleSubdued(`[${log.level}] \t ${log.origin} \t ${log.text}`);
|
||||||
console.log(`[${log.level}] \t ${log.origin} \t ${log.text}`);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,22 @@
|
|||||||
/* eslint-disable no-console */
|
/* eslint-disable no-console */
|
||||||
|
import { consoleHighlight, consoleRed } from './utils/console.js';
|
||||||
import { initAssets, startIntegrations, startServer } from './app.js';
|
import { initAssets, startIntegrations, startServer } from './app.js';
|
||||||
|
|
||||||
async function startOntime() {
|
async function startOntime() {
|
||||||
try {
|
try {
|
||||||
console.log('Request: Initialise assets...');
|
console.log('\n');
|
||||||
|
consoleHighlight('Request: Initialise assets...');
|
||||||
await initAssets();
|
await initAssets();
|
||||||
console.log('Request: Start server...');
|
|
||||||
|
console.log('\n');
|
||||||
|
consoleHighlight('Request: Start server...');
|
||||||
await startServer();
|
await startServer();
|
||||||
console.log('Request: Start integrations...');
|
|
||||||
|
console.log('\n');
|
||||||
|
consoleHighlight('Request: Start integrations...');
|
||||||
await startIntegrations();
|
await startIntegrations();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(`Request failed: ${error}`);
|
consoleRed(`Request failed: ${error}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,13 +3,55 @@
|
|||||||
/**
|
/**
|
||||||
* Utility function to log messages in green
|
* Utility function to log messages in green
|
||||||
*/
|
*/
|
||||||
export function consoleGreen(message: string) {
|
export function consoleSuccess(message: string) {
|
||||||
console.log(`\x1b[32m${message}\x1b[0m`);
|
console.log(inGreen(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility function to log messages in red
|
* Utility function to log messages in red
|
||||||
*/
|
*/
|
||||||
export function consoleRed(message: string) {
|
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