From a6ca4ffba011c5ff29cc9d7d6e6d59582ea18744 Mon Sep 17 00:00:00 2001 From: chronolaw Date: Thu, 13 Jun 2024 11:37:43 +0800 Subject: [PATCH] style(pdk/log): simplify buffer:put with vararg-style --- kong/pdk/log.lua | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/kong/pdk/log.lua b/kong/pdk/log.lua index 6f9c07c56569..adcca23dfc9b 100644 --- a/kong/pdk/log.lua +++ b/kong/pdk/log.lua @@ -152,29 +152,29 @@ local serializers = { end, [2] = function(buf, sep, to_string, ...) - buf:put(to_string((select(1, ...)))):put(sep) - :put(to_string((select(2, ...)))) + buf:put(to_string((select(1, ...))), sep, + to_string((select(2, ...)))) end, [3] = function(buf, sep, to_string, ...) - buf:put(to_string((select(1, ...)))):put(sep) - :put(to_string((select(2, ...)))):put(sep) - :put(to_string((select(3, ...)))) + buf:put(to_string((select(1, ...))), sep, + to_string((select(2, ...))), sep, + to_string((select(3, ...)))) end, [4] = function(buf, sep, to_string, ...) - buf:put(to_string((select(1, ...)))):put(sep) - :put(to_string((select(2, ...)))):put(sep) - :put(to_string((select(3, ...)))):put(sep) - :put(to_string((select(4, ...)))) + buf:put(to_string((select(1, ...))), sep, + to_string((select(2, ...))), sep, + to_string((select(3, ...))), sep, + to_string((select(4, ...)))) end, [5] = function(buf, sep, to_string, ...) - buf:put(to_string((select(1, ...)))):put(sep) - :put(to_string((select(2, ...)))):put(sep) - :put(to_string((select(3, ...)))):put(sep) - :put(to_string((select(4, ...)))):put(sep) - :put(to_string((select(5, ...)))) + buf:put(to_string((select(1, ...))), sep, + to_string((select(2, ...))), sep, + to_string((select(3, ...))), sep, + to_string((select(4, ...))), sep, + to_string((select(5, ...)))) end, } @@ -334,7 +334,7 @@ local function gen_log_func(lvl_const, imm_buf, to_string, stack_level, sep) else for i = 1, n - 1 do - variadic_buf:put(to_string((select(i, ...)))):put(sep or "") + variadic_buf:put(to_string((select(i, ...))), sep or "") end variadic_buf:put(to_string((select(n, ...)))) end