Debugging Lua
Debugging allows you to detect, diagnose, and eliminate errors in a program. Generally speaking, debugging a program involves logic checking and variable-value viewing. For Lua in Redis, a debugging tool was introduced in version 3.2 to make the debugging process much easier, and there are some functions that can help you to print logs for debugging. In this recipe, we'll see how to achieve these debugging steps in Redis.
Getting ready…
You need to finish the installation of the Redis Server as we described in the Downloading and installing Redis recipe in Chapter 1, Getting Started with Redis.
For logging in Redis, you have to set the following configurations in redis.conf
:
logfile "/redis/log/redis.log"
loglevel debug
Then, you can start the Redis Server with the configuration file, as we have shown in the Starting and shutting down Redis recipe in Chapter 1, Getting Started with Redis.
How to do it...
Let's take the Lua script introduced in the previous recipe to show how to debug...