Commit 85efe896 by Edward Thomson

tests: display trace level with prefix in tests

parent 625a3a49
...@@ -10,26 +10,42 @@ struct method { ...@@ -10,26 +10,42 @@ struct method {
void (*close)(void); void (*close)(void);
}; };
static const char *message_prefix(git_trace_level_t level)
{
switch (level) {
case GIT_TRACE_NONE:
return "[NONE]: ";
case GIT_TRACE_FATAL:
return "[FATAL]: ";
case GIT_TRACE_ERROR:
return "[ERROR]: ";
case GIT_TRACE_WARN:
return "[WARN]: ";
case GIT_TRACE_INFO:
return "[INFO]: ";
case GIT_TRACE_DEBUG:
return "[DEBUG]: ";
case GIT_TRACE_TRACE:
return "[TRACE]: ";
default:
return "[?????]: ";
}
}
#if defined(GIT_TRACE) #if defined(GIT_TRACE)
static void _git_trace_cb__printf(git_trace_level_t level, const char *msg) static void _git_trace_cb__printf(git_trace_level_t level, const char *msg)
{ {
/* TODO Use level to print a per-message prefix. */ printf("%s%s\n", message_prefix(level), msg);
GIT_UNUSED(level);
printf("%s\n", msg);
} }
#if defined(GIT_WIN32) #if defined(GIT_WIN32)
static void _git_trace_cb__debug(git_trace_level_t level, const char *msg) static void _git_trace_cb__debug(git_trace_level_t level, const char *msg)
{ {
/* TODO Use level to print a per-message prefix. */ OutputDebugString(message_prefix(level));
GIT_UNUSED(level);
OutputDebugString(msg); OutputDebugString(msg);
OutputDebugString("\n"); OutputDebugString("\n");
printf("%s\n", msg); printf("%s%s\n", message_prefix(level), msg);
} }
#else #else
#define _git_trace_cb__debug _git_trace_cb__printf #define _git_trace_cb__debug _git_trace_cb__printf
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment