bug: syslog error messages run together with the underlying error (missing separator)
Current Behavior
In apisix/plugins/syslog/init.lua, send_syslog_data builds its two error messages by concatenating the underlying error directly onto the message text, with no separator:
err_msg = "failed when initiating the sys logger processor".. err -- line 67
...
err_msg = "failed to log message" .. err -- line 76err_msg is returned to the batch processor, which writes it verbatim to error.log (apisix/utils/batch-processor.lua, core.log.error("Batch Processor[", ..., "]: ", err)). The message and the real cause run together into one unreadable token, for example:
failed when initiating the sys logger processorconnection refused
failed to log messagebuffer overflowEvery other error string in the same code base uses a ": " separator (e.g. 'failed to open /dev/urandom: ' .. err, 'failed to loadstring: ' .. err).
Expected Behavior
The underlying error is separated from the message, consistent with the rest of the code base:
failed when initiating the sys logger processor: connection refused
failed to log message: buffer overflowError Logs
Not captured from a live run. The strings above are derived from the concatenation at lines 67 and 76 of apisix/plugins/syslog/init.lua on master.
Steps to Reproduce
- Enable the
syslogplugin on a route withhost/portpointing at an unreachable syslog server, usingsock_type: "tcp". - Send a request through the route so the batch processor flushes.
- Read
logs/error.logand look at theBatch Processor[syslog logger]error line: the failure reason is glued to the message text with no separator.
Note: this is separate from #13969 (nil-index crash when logger init fails). It concerns only the formatting of the messages, and applies to the "failed to log message" path too.
Environment
- APISIX version (run
apisix version): 3.18.0 (master @ 3234caa2) - Operating system (run
uname -a): N/A (found by code inspection) - OpenResty / Nginx version (run
openresty -Vornginx -V): N/A - etcd version, if relevant: N/A
- APISIX Dashboard version, if relevant: N/A
- Plugin runner version, for issues related to plugin runners: N/A
- LuaRocks version, for installation issues: N/A
Source: apache/apisix