Kouhei Sutou
null+****@clear*****
Sat May 21 18:37:30 JST 2016
Kouhei Sutou 2016-05-21 18:37:30 +0900 (Sat, 21 May 2016) New Revision: 49e51f97264f15a34e5fe448211ac54e06881348 https://github.com/groonga/groonga/commit/49e51f97264f15a34e5fe448211ac54e06881348 Message: Add grn_logger_putv() for delegation Modified files: include/groonga/groonga.h lib/logger.c Modified: include/groonga/groonga.h (+7 -0) =================================================================== --- include/groonga/groonga.h 2016-05-21 17:26:47 +0900 (9889456) +++ include/groonga/groonga.h 2016-05-21 18:37:30 +0900 (7ba7484) @@ -1044,6 +1044,13 @@ GRN_API grn_log_level grn_logger_get_max_level(grn_ctx *ctx); GRN_API void grn_logger_put(grn_ctx *ctx, grn_log_level level, const char *file, int line, const char *func, const char *fmt, ...) GRN_ATTRIBUTE_PRINTF(6); +GRN_API void grn_logger_putv(grn_ctx *ctx, + grn_log_level level, + const char *file, + int line, + const char *func, + const char *fmt, + va_list ap); GRN_API void grn_logger_reopen(grn_ctx *ctx); GRN_API grn_bool grn_logger_pass(grn_ctx *ctx, grn_log_level level); Modified: lib/logger.c (+23 -6) =================================================================== --- lib/logger.c 2016-05-21 17:26:47 +0900 (f8e475b) +++ lib/logger.c 2016-05-21 18:37:30 +0900 (8dbb408) @@ -353,8 +353,28 @@ grn_logger_pass(grn_ctx *ctx, grn_log_level level) #define LBUFSIZE 0x400 void -grn_logger_put(grn_ctx *ctx, grn_log_level level, - const char *file, int line, const char *func, const char *fmt, ...) +grn_logger_put(grn_ctx *ctx, + grn_log_level level, + const char *file, + int line, + const char *func, + const char *fmt, + ...) +{ + va_list ap; + va_start(ap, fmt); + grn_logger_putv(ctx, level, file, line, func, fmt, ap); + va_end(ap); +} + +void +grn_logger_putv(grn_ctx *ctx, + grn_log_level level, + const char *file, + int line, + const char *func, + const char *fmt, + va_list ap) { if (level <= current_logger.max_level && current_logger.log) { char tbuf[TBUFSIZE]; @@ -367,10 +387,7 @@ grn_logger_put(grn_ctx *ctx, grn_log_level level, grn_timeval2str(ctx, &tv, tbuf, TBUFSIZE); } if (current_logger.flags & GRN_LOG_MESSAGE) { - va_list argp; - va_start(argp, fmt); - grn_vsnprintf(mbuf, MBUFSIZE - 1, fmt, argp); - va_end(argp); + grn_vsnprintf(mbuf, MBUFSIZE - 1, fmt, ap); mbuf[MBUFSIZE - 1] = '\0'; } else { mbuf[0] = '\0'; -------------- next part -------------- HTML����������������������������... Télécharger