]> johannes.truschnigg.info Git - netconsole-rx/commitdiff
Use string.format instead of concat for stderr output
authorJohannes Truschnigg <johannes@truschnigg.info>
Wed, 12 Jul 2023 17:00:54 +0000 (19:00 +0200)
committerJohannes Truschnigg <johannes@truschnigg.info>
Wed, 12 Jul 2023 17:02:50 +0000 (19:02 +0200)
netconsole-rx.lua

index d16d9ba51594bea2295689711161684c2b21c4e1..9e336b6ae68033cd29a1d6f17734ed4d8949f986 100755 (executable)
@@ -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