1
0
mirror of https://github.com/preble/libpinproc synced 2026-02-24 18:25:23 +01:00

Added log levels. Fixed bug in PRDevice::Open() if VerifyChipID() worked the first time.

This commit is contained in:
Adam Preble
2009-05-30 14:43:48 -04:00
parent 495d688106
commit 87c73a1f06
6 changed files with 69 additions and 59 deletions

View File

@@ -31,19 +31,23 @@
#include "../include/pinproc.h"
#include "PRDevice.h"
typedef void (*PRLogCallback)(const char *text);
typedef void (*PRLogCallback)(PRLogLevel level, const char *text);
PRLogCallback logCallback = NULL;
PRLogLevel logLevel = kPRLogError;
void PRLog(const char *format, ...)
void PRLog(PRLogLevel level, const char *format, ...)
{
if (level < logLevel)
return;
const int maxLogLineLength = 1024;
char line[maxLogLineLength];
va_list ap;
va_start(ap, format);
vsnprintf(line, maxLogLineLength, format, ap);
if (logCallback)
logCallback(line);
logCallback(level, line);
else
fprintf(stderr, line);
}