Commit 24887c6e authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

log: Add generic __print_on_level helper

It accepts va_list argument and suitable to
be wrapped with another helpers.
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent c406ccc0
...@@ -152,9 +152,8 @@ unsigned int log_get_loglevel(void) ...@@ -152,9 +152,8 @@ unsigned int log_get_loglevel(void)
return current_loglevel; return current_loglevel;
} }
void print_on_level(unsigned int loglevel, const char *format, ...) static void __print_on_level(unsigned int loglevel, const char *format, va_list params)
{ {
va_list params;
int fd, size, ret, off; int fd, size, ret, off;
if (unlikely(loglevel == LOG_MSG)) { if (unlikely(loglevel == LOG_MSG)) {
...@@ -168,10 +167,7 @@ void print_on_level(unsigned int loglevel, const char *format, ...) ...@@ -168,10 +167,7 @@ void print_on_level(unsigned int loglevel, const char *format, ...)
off = 0; off = 0;
} }
va_start(params, format); size = vsnprintf(buffer + buf_off, PAGE_SIZE - buf_off, format, params);
size = vsnprintf(buffer + buf_off, PAGE_SIZE - buf_off, format, params);
va_end(params);
size += buf_off; size += buf_off;
while (off < size) { while (off < size) {
...@@ -181,3 +177,12 @@ void print_on_level(unsigned int loglevel, const char *format, ...) ...@@ -181,3 +177,12 @@ void print_on_level(unsigned int loglevel, const char *format, ...)
off += ret; off += ret;
} }
} }
void print_on_level(unsigned int loglevel, const char *format, ...)
{
va_list params;
va_start(params, format);
__print_on_level(loglevel, format, params);
va_end(params);
}
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