parser-helper: Make parser_helper_log a function

This commit is contained in:
Tobias Brunner
2014-05-15 11:28:10 +02:00
parent 4b670a20a9
commit c976cc7d33
2 changed files with 28 additions and 9 deletions
+27
View File
@@ -15,6 +15,7 @@
#include <limits.h>
#include <ctype.h>
#include <stdarg.h>
#include "parser_helper.h"
@@ -196,6 +197,32 @@ METHOD(parser_helper_t, destroy, void,
free(this);
}
/**
* Described in header
*/
void parser_helper_log(int level, parser_helper_t *ctx, char *fmt, ...)
{
parser_helper_file_t *file;
char msg[8192];
va_list args;
int line;
va_start(args, fmt);
vsnprintf(msg, sizeof(msg), fmt, args);
va_end(args);
file = ctx->file_current(ctx);
line = ctx->get_lineno ? ctx->get_lineno(ctx->scanner) : 0;
if (file)
{
dbg(DBG_CFG, level, "%s:%d: %s", file->name, line, msg);
}
else
{
dbg(DBG_CFG, level, "%s", msg);
}
}
/**
* Described in header
*/