add a log level flag

This commit is contained in:
tildearrow 2021-06-09 12:28:46 -05:00
parent 2be720540f
commit 86131bf05e
4 changed files with 21 additions and 1 deletions

View file

@ -757,6 +757,7 @@ bool DivEngine::init() {
dispatch=new DivPlatformPCE;
break;
default:
logW("this system is not supported yet! using dummy platform.\n");
dispatch=new DivPlatformDummy;
break;
}

View file

@ -1,5 +1,7 @@
#include "ta-log.h"
int logLevel=LOGLEVEL_INFO;
int logD(const char* format, ...) {
va_list va;
int ret;

View file

@ -54,6 +54,22 @@ bool pView(String val) {
return true;
}
bool pLogLevel(String val) {
if (val=="debug") {
logLevel=LOGLEVEL_DEBUG;
} else if (val=="info") {
logLevel=LOGLEVEL_INFO;
} else if (val=="warning") {
logLevel=LOGLEVEL_WARN;
} else if (val=="error") {
logLevel=LOGLEVEL_ERROR;
} else {
logE("invalid value for loglevel! valid values are: debug, info, warning, error.\n");
return false;
}
return true;
}
bool pVersion(String) {
printf("Furnace version " DIV_VERSION ".\n\n");
printf("developed by tildearrow. copyright (C) 2021.\n");
@ -95,6 +111,7 @@ void initParams() {
params.push_back(TAParam("h","help",false,pHelp,"","display this help"));
params.push_back(TAParam("a","audio",true,pAudio,"jack|sdl","set audio engine (SDL by default)"));
params.push_back(TAParam("L","loglevel",true,pLogLevel,"debug|info|warning|error","set the log level (info by default)"));
params.push_back(TAParam("v","view",true,pView,"pattern|commands|nothing","set visualization (pattern by default)"));
params.push_back(TAParam("V","version",false,pVersion,"","view information about Furnace."));

View file

@ -8,7 +8,7 @@
#define LOGLEVEL_INFO 2
#define LOGLEVEL_DEBUG 3
#define logLevel 3
extern int logLevel;
int logD(const char* format, ...);
int logI(const char* format, ...);