This is an automated email from the ASF dual-hosted git repository.

LiteSun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
     new 7577c3173 fix(syslog): separate error cause from message in syslog 
errors (#13974)
7577c3173 is described below

commit 7577c31733bf0f7067cda6af3153b2a56ec8c6f5
Author: Bhuvan Somisetty <[email protected]>
AuthorDate: Thu Nov 5 14:59:35 2026 +0530

    fix(syslog): separate error cause from message in syslog errors (#13974)
---
 apisix/plugins/syslog/init.lua |  4 +--
 t/plugin/syslog.t              | 59 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 61 insertions(+), 2 deletions(-)

diff --git a/apisix/plugins/syslog/init.lua b/apisix/plugins/syslog/init.lua
index 15f1eb2b6..d80307cc0 100644
--- a/apisix/plugins/syslog/init.lua
+++ b/apisix/plugins/syslog/init.lua
@@ -64,7 +64,7 @@ local function send_syslog_data(conf, log_message, api_ctx)
 
     if not logger then
         res = false
-        err_msg = "failed when initiating the sys logger processor".. err
+        err_msg = "failed when initiating the sys logger processor: " .. err
     end
 
     -- reuse the logger object
@@ -72,7 +72,7 @@ local function send_syslog_data(conf, log_message, api_ctx)
 
     if not ok then
         res = false
-        err_msg = "failed to log message" .. err
+        err_msg = "failed to log message: " .. err
     end
 
     return res, err_msg
diff --git a/t/plugin/syslog.t b/t/plugin/syslog.t
index e8268fe8b..451a26d1b 100644
--- a/t/plugin/syslog.t
+++ b/t/plugin/syslog.t
@@ -687,3 +687,62 @@ GET /t
 GET /t
 --- error_log
 "body":"hello world\n"
+
+
+
+=== TEST 22: add syslog plugin for the send failure test
+--- config
+    location /t {
+        content_by_lua_block {
+            local t = require("lib.test_admin").test
+            t('/apisix/admin/plugin_metadata/syslog', ngx.HTTP_DELETE)
+            local code, body = t('/apisix/admin/routes/1',
+                 ngx.HTTP_PUT,
+                 [[{
+                        "plugins": {
+                            "syslog": {
+                                "batch_max_size": 1,
+                                "flush_limit": 1,
+                                "host" : "127.0.0.1",
+                                "port" : 5140
+                            }
+                        },
+                        "upstream": {
+                            "nodes": {
+                                "127.0.0.1:1980": 1
+                            },
+                            "type": "roundrobin"
+                        },
+                        "uri": "/hello"
+                }]]
+                )
+            if code >= 300 then
+                ngx.status = code
+            end
+            ngx.say(body)
+        }
+    }
+--- request
+GET /t
+--- response_body
+passed
+
+
+
+=== TEST 23: hit route, send failure is reported with a separator before the 
cause
+--- extra_init_by_lua
+    local logger_socket = require("resty.logger.socket")
+    logger_socket.new = function()
+        return {
+            log = function()
+                return nil, "mocked send failure"
+            end
+        }
+    end
+--- request
+GET /hello
+--- response_body
+hello world
+--- wait: 0.5
+--- error_log
+failed to log message: mocked send failure

Reply via email to