Commit 59e829f3 authored by Mike Gabriel's avatar Mike Gabriel

nxcompshad: Rewrite Logger class methods to properly take advantage of the…

nxcompshad: Rewrite Logger class methods to properly take advantage of the 'gnu_printf' format attribute.
parent 8f5ce18d
......@@ -41,11 +41,14 @@
Logger logger;
void Logger::user(const char *format, va_list arguments)
void Logger::user(const char *format, ...)
{
char string[1024];
va_list arguments;
va_start(arguments, format);
vsnprintf(string, 1024, format, arguments);
va_end(arguments);
fprintf(stderr, "%s\n", string);
}
......@@ -56,20 +59,26 @@ void Logger::error(const char *name, int error)
name, error, strerror(error));
}
void Logger::warning(const char *name, const char *format, va_list arguments)
void Logger::warning(const char *name, const char *format, ...)
{
char string[1024];
va_list arguments;
va_start(arguments, format);
vsnprintf(string, 1024, format, arguments);
va_end(arguments);
fprintf(stderr, "%s: WARNING! %s\n", name, string);
}
void Logger::test(const char *name, const char *format, va_list arguments)
void Logger::test(const char *name, const char *format, ...)
{
char string[1024];
va_list arguments;
va_start(arguments, format);
vsnprintf(string, 1024, format, arguments);
va_end(arguments);
fprintf(stderr, "%s: %s\n", name, string);
}
......@@ -79,11 +88,14 @@ void Logger::trace(const char *name)
fprintf(stderr, "%s\n", name);
}
void Logger::debug(const char *name, const char *format, va_list arguments)
void Logger::debug(const char *name, const char *format, ...)
{
char string[1024];
va_list arguments;
va_start(arguments, format);
vsnprintf(string, 1024, format, arguments);
va_end(arguments);
fprintf(stderr, "%s: %s\n", name, string);
}
......
......@@ -43,17 +43,17 @@ class Logger
{
public:
void user(const char *format, va_list arguments);
void user(const char *format, ...) __attribute__((format(gnu_printf, 2, 3)));
void error(const char *name, int error);
void warning(const char *name, const char *format, va_list arguments);
void warning(const char *name, const char *format, ...) __attribute__((format(gnu_printf, 3, 4)));
void test(const char *name, const char *format, va_list arguments);
void test(const char *name, const char *format, ...) __attribute__((format(gnu_printf, 3, 4)));
void trace(const char *name);
void debug(const char *name, const char *format, va_list arguments);
void debug(const char *name, const char *format, ...) __attribute__((format(gnu_printf, 3, 4)));
void dump(const char *name, const char *data, int size);
};
......
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