Redis: print to STDOUT from a LUA script

When you want to print to STDOUT from a LUA script executed by “redis-cli –raw –eval”, it doesn’t print to STDOUT but in Syslog. You will need to use “return” instead.

Let’s help yourself with a “logit” function, like this:

local log = {}
local function logit(msg)
  log[#log+1] = msg

-- Some code

    -- Log my string

-- Some more code

-- print log to STDOUT
return log

That’s awesome till you don’t know how to pass arguments to your Redis LUA script ! :-)

Leave a Reply

Your email address will not be published. Required fields are marked *