# Best practices for Kong debugging + example

**URL:** <https://discuss.konghq.com/t/best-practices-for-kong-debugging-example/182>\
**Category:** Questions\
**Created:** [December 14, 2017, 6:20am UTC](https://discuss.konghq.com/t/best-practices-for-kong-debugging-example/182 "2017-12-14T06:20:31Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Tieske](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/tieske/32/54_2.png) [@Tieske](https://discuss.konghq.com/u/Tieske)\
**Post date:** [December 15, 2017, 8:26am UTC](https://discuss.konghq.com/t/best-practices-for-kong-debugging-example/182/3 "2017-12-15T08:26:39Z")

</div>

same here. Despite that I use ZeroBraneStudio for coding, I do not use the debugger, but use a `tail` on the regular logs.

for quick stuff I add debug lines like:  
`print(require("pl.pretty").write({..parameters here...})`

For more elaborate work I temporarily insert a function like this:

```
--- Debug function for development purposes.
-- Will dump all passed in parameters in a pretty-printed way
-- as a `warning` log message. Includes color markers to make it stand out.
-- @param ... list of parameters to dump
local dump = function(...)
  local info = debug.getinfo(2) or {}
  local input = { n = select("#", ...), ...}
  local write = require("pl.pretty").write
  local serialized
  if input.n == 1 and type(input[1]) == "table" then
    serialized = "(" .. type(input[1]) .. "): " .. write(input[1])
  elseif input.n == 1 then
    serialized = "(" .. type(input[1]) .. "): " .. tostring(input[1]) .. "\n"
  else
    local n
    n, input.n = input.n, nil
    serialized = "(list, #" .. n .. "): " .. write(input)
  end

  ngx.log(ngx.WARN,
          "\027[31m\n",
          "function '", tostring(info.name), ":" , tostring(info.currentline),
          "' in '", tostring(info.short_src), "' wants you to know:\n",
          serialized,
          "\027[0m")
end
```

---

_[View the full topic](https://discuss.konghq.com/t/best-practices-for-kong-debugging-example/182)._
