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
end

-- Some code

    -- Log my string
    logit(mystring)

-- 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 *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>