Spectre/System/Log: adding debug method.
This commit is contained in:
parent
eb1f6303f1
commit
1a6cee0b25
2 changed files with 20 additions and 2 deletions
|
|
@ -15,6 +15,7 @@ public :
|
||||||
T_WARNING = 1 << 0,
|
T_WARNING = 1 << 0,
|
||||||
T_CRITICAL = 1 << 1,
|
T_CRITICAL = 1 << 1,
|
||||||
T_ERROR = 1 << 2,
|
T_ERROR = 1 << 2,
|
||||||
|
T_DEBUG = 1 << 3
|
||||||
};
|
};
|
||||||
|
|
||||||
static void info(const char *message, ...);
|
static void info(const char *message, ...);
|
||||||
|
|
@ -23,6 +24,8 @@ public :
|
||||||
|
|
||||||
static int error(const char *message, ...);
|
static int error(const char *message, ...);
|
||||||
|
|
||||||
|
static void debug(const char *message, ...);
|
||||||
|
|
||||||
private :
|
private :
|
||||||
|
|
||||||
static void writeln(Type type, const char *fmt, va_list args);
|
static void writeln(Type type, const char *fmt, va_list args);
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,17 @@ int Log::error(const char *message, ...)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Log::debug(const char *message, ...)
|
||||||
|
{
|
||||||
|
#ifdef SPECTRE_DEBUG
|
||||||
|
va_list vl;
|
||||||
|
|
||||||
|
va_start(vl, message);
|
||||||
|
writeln(T_DEBUG, message, vl);
|
||||||
|
va_end(vl);
|
||||||
|
#endif /* SPECTRE_DEBUG */
|
||||||
|
}
|
||||||
|
|
||||||
void Log::writeln(Type type, const char *message, va_list args)
|
void Log::writeln(Type type, const char *message, va_list args)
|
||||||
{
|
{
|
||||||
FILE *fd = stderr;
|
FILE *fd = stderr;
|
||||||
|
|
@ -52,8 +63,12 @@ void Log::writeln(Type type, const char *message, va_list args)
|
||||||
case T_CRITICAL:
|
case T_CRITICAL:
|
||||||
prefix = "CRIT";
|
prefix = "CRIT";
|
||||||
break;
|
break;
|
||||||
default :
|
#ifdef SPECTRE_DEBUG
|
||||||
case T_ERROR :
|
case T_DEBUG:
|
||||||
|
prefix = "DEBUG";
|
||||||
|
break;
|
||||||
|
#endif /* SPECTRE_DEBUG */
|
||||||
|
case T_ERROR : default :
|
||||||
prefix = "ERROR";
|
prefix = "ERROR";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue