add a new log level (trace)

This commit is contained in:
tildearrow 2022-03-23 22:05:09 -05:00
parent 711b60d454
commit 47d7722f6e
5 changed files with 28 additions and 2 deletions

View File

@ -190,6 +190,7 @@ class DivEngine {
bool forceMono;
bool cmdStreamEnabled;
bool softLocked;
int softLockCount;
int ticks, curRow, curOrder, remainingLoops, nextSpeed;
double divider;
int cycles;
@ -681,6 +682,8 @@ class DivEngine {
halted(false),
forceMono(false),
cmdStreamEnabled(false),
softLocked(0),
softLockCount(0),
ticks(0),
curRow(0),
curOrder(0),

View File

@ -1410,6 +1410,7 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi
if (softLocked) {
if (!isBusy.try_lock()) {
logV("audio is soft-locked (%d)\n",softLockCount++);
return;
}
} else {

View File

@ -17,10 +17,28 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
// TODO: improve these routines to allow logging to memory for eventual log window!
#include "ta-log.h"
int logLevel=LOGLEVEL_INFO;
int logV(const char* format, ...) {
va_list va;
int ret;
if (logLevel<LOGLEVEL_TRACE) return 0;
#ifdef _WIN32
printf("[trace] ");
#else
printf("\x1b[1;37m[trace]\x1b[m ");
#endif
va_start(va,format);
ret=vprintf(format,va);
va_end(va);
fflush(stdout);
return ret;
}
int logD(const char* format, ...) {
va_list va;
int ret;

View File

@ -109,7 +109,9 @@ bool pConsole(String val) {
}
bool pLogLevel(String val) {
if (val=="debug") {
if (val=="trace") {
logLevel=LOGLEVEL_TRACE;
} else if (val=="debug") {
logLevel=LOGLEVEL_DEBUG;
} else if (val=="info") {
logLevel=LOGLEVEL_INFO;
@ -118,7 +120,7 @@ bool pLogLevel(String val) {
} else if (val=="error") {
logLevel=LOGLEVEL_ERROR;
} else {
logE("invalid value for loglevel! valid values are: debug, info, warning, error.\n");
logE("invalid value for loglevel! valid values are: trace, debug, info, warning, error.\n");
return false;
}
return true;

View File

@ -26,9 +26,11 @@
#define LOGLEVEL_WARN 1
#define LOGLEVEL_INFO 2
#define LOGLEVEL_DEBUG 3
#define LOGLEVEL_TRACE 4
extern int logLevel;
int logV(const char* format, ...);
int logD(const char* format, ...);
int logI(const char* format, ...);
int logW(const char* format, ...);