From: Johannes Truschnigg Date: Wed, 12 Jul 2023 17:00:54 +0000 (+0200) Subject: Use string.format instead of concat for stderr output X-Git-Url: https://johannes.truschnigg.info/gitweb/?a=commitdiff_plain;h=20afbfe2b28446833adb8c32cdb59d6c313bf46b;p=netconsole-rx Use string.format instead of concat for stderr output --- diff --git a/netconsole-rx.lua b/netconsole-rx.lua index d16d9ba..9e336b6 100755 --- a/netconsole-rx.lua +++ b/netconsole-rx.lua @@ -46,7 +46,7 @@ function args_parse() elseif opt:find("outfile=", 1, true) then outfile = opt:match("[^%c]+", 9) else - io.stderr:write("FATAL: unsupported option: " .. opt .. "\n") + io.stderr:write(string.format("FATAL: unsupported option: '%s'\n", opt)) os.exit(1) end end @@ -70,7 +70,7 @@ function args_validate() outp, err = io.open(outfile, "w+") if err then args_valid=false - io.stderr:write("FATAL: failed to open output stream at '", outfile, "'\n") + io.stderr:write(string.format("FATAL: failed to open output stream at '%s'\n", outfile)) end end @@ -81,7 +81,7 @@ function args_validate() pidf:close() else args_valid=false - io.stderr:write("FATAL: failed to record PID info in '", pidfile, "'\n") + io.stderr:write(string.format("FATAL: failed to record PID info in '%s'\n", pidfile)) end end @@ -101,7 +101,7 @@ end udpl:setsockname("*", listenport) udpl:settimeout(0.1) outp:setvbuf("line") -io.stderr:write("netconsole-rx.lua | pid " .. mypid .. " | input UDP port " .. listenport .. " | output '" .. outfile .. "'\n") +io.stderr:write(string.format("%s INFO: netconsole-rx.lua | pid %d | input udp port %d | output %s\n", isoutctime(), mypid, listenport, outfile)) -- processing loop -- @@ -123,7 +123,7 @@ do -- outp:write(string.format("%s:%s \t%s\n", peer, peerport, mdata)) outp:write(string.format("%s %s:%s \t%s\n", isoutctime(), peer, peerport, data)) else - io.stderr:write("WARN: garbage input from peer " .. peer .. ":" .. peerport .. " discarded\n") + io.stderr:write(string.format("%s WARN: garbage input from peer %s:%d discarded\n", isoutctime(), peer, peerport)) end end end