mirror of
https://github.com/LucasDower/ObjToSchematic.git
synced 2025-02-23 13:49:07 +08:00
Added toggle for warning logs
This commit is contained in:
parent
88ec544d3a
commit
5b84c76a75
@ -24,6 +24,7 @@ export class AppContext {
|
||||
public constructor() {
|
||||
Logger.Get.enableLOG();
|
||||
Logger.Get.enableLOGMAJOR();
|
||||
Logger.Get.enableLOGWARN();
|
||||
|
||||
const gl = (<HTMLCanvasElement>document.getElementById('canvas')).getContext('webgl');
|
||||
if (!gl) {
|
||||
|
@ -18,7 +18,15 @@ export const LOG_MAJOR = (...data: any[]) => {
|
||||
}
|
||||
}
|
||||
|
||||
export const LOG_WARN = console.warn;
|
||||
/**
|
||||
* Performs console.warn if logging LOG_WARN is enabled
|
||||
*/
|
||||
export const LOG_WARN = (...data: any[]) => {
|
||||
if (Logger.Get.isLOGWARNEnabled()) {
|
||||
console.log(...data);
|
||||
}
|
||||
}
|
||||
|
||||
export const LOG_ERROR = console.error;
|
||||
export const TIME_START = console.time;
|
||||
export const TIME_END = console.timeEnd;
|
||||
@ -33,6 +41,7 @@ export class Logger {
|
||||
|
||||
private _enabledLOG = false;
|
||||
private _enabledLOGMAJOR = false;
|
||||
private _enabledLOGWARN = false;
|
||||
|
||||
private constructor() {
|
||||
}
|
||||
@ -53,6 +62,14 @@ export class Logger {
|
||||
this._enabledLOGMAJOR = false;
|
||||
}
|
||||
|
||||
public enableLOGWARN() {
|
||||
this._enabledLOGWARN = true;
|
||||
}
|
||||
|
||||
public disableLOGWARN() {
|
||||
this._enabledLOGWARN = false;
|
||||
}
|
||||
|
||||
public isLOGEnabled() {
|
||||
return this._enabledLOG;
|
||||
}
|
||||
@ -60,4 +77,8 @@ export class Logger {
|
||||
public isLOGMAJOREnabled() {
|
||||
return this._enabledLOGMAJOR;
|
||||
}
|
||||
|
||||
public isLOGWARNEnabled() {
|
||||
return this._enabledLOGWARN;
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ import { headlessConfig } from './headless-config';
|
||||
import { AssignParams, ExportParams, ImportParams, VoxeliseParams } from '../src/worker_types';
|
||||
import { WorkerClient } from '../src/worker_client';
|
||||
import { StatusHandler } from '../src/status';
|
||||
import { LOG_MAJOR } from '../src/util/log_util';
|
||||
import { Logger, LOG_MAJOR } from '../src/util/log_util';
|
||||
|
||||
export type THeadlessConfig = {
|
||||
import: ImportParams.Input,
|
||||
@ -10,11 +10,19 @@ export type THeadlessConfig = {
|
||||
assign: AssignParams.Input,
|
||||
export: ExportParams.Input,
|
||||
debug: {
|
||||
logging: boolean,
|
||||
showLogs: boolean,
|
||||
showWarnings: boolean,
|
||||
}
|
||||
}
|
||||
|
||||
export function runHeadless() {
|
||||
if (headlessConfig.debug.showLogs) {
|
||||
Logger.Get.enableLOGMAJOR();
|
||||
}
|
||||
if (headlessConfig.debug.showWarnings) {
|
||||
Logger.Get.enableLOGWARN();
|
||||
}
|
||||
|
||||
const worker = WorkerClient.Get;
|
||||
{
|
||||
LOG_MAJOR('Importing...');
|
||||
|
@ -1,12 +1,7 @@
|
||||
import { Logger, LOG_MAJOR } from '../src/util/log_util';
|
||||
import { LOG_MAJOR } from '../src/util/log_util';
|
||||
import { runHeadless } from './headless';
|
||||
import { headlessConfig } from './headless-config';
|
||||
|
||||
void async function main() {
|
||||
if (headlessConfig.debug.logging) {
|
||||
Logger.Get.enableLOGMAJOR();
|
||||
}
|
||||
|
||||
runHeadless();
|
||||
|
||||
LOG_MAJOR('Finished!');
|
||||
|
Loading…
Reference in New Issue
Block a user