Giter Club home page Giter Club logo

lua-resty-vardump's Introduction

Name

lua-resty-vardump - A debug tool for the Openresty/ngx_lua

Table of Contents

Description

Vardump is a debug tool for the Openresty/ngx_lua that pretty-prints some Lua values.

Synopsis

local vardump = require 'resty.vardump'

local my_t = {
  a = 1,
  b = "str",
  c = function ()
    return 3
  end,
  d = ngx.null,
  e = ngx.var,
  f = nil,
  g = vardump,
  h = false,
  i = tostring
}

local my_num_var = 12345
local my_str_var = "hello, world"
local my_arr_var = {"a", "b"} 

vardump.dump(my_t, my_num_var, my_str_var, my_arr_var)

vardump.depth(1).dd(my_t)

ngx.print('This line will not be executed')

Output:

Screenshot

Methods

dump

syntax: vardump.dump(...)

Pretty print given values.

dd

syntax: vardump.dd(...)

Pretty print given values then stop the code execution.

depth

syntax: vardump.depth(max_depth)

Set the max traversal depth when dumping your Lua values.

The default value of max depth is 15.

Attributes

html

syntax: vardump.html = false

default: true

Set the print mode.

true: Print in HTML format.

false: Print in plain text format.

send_content_type_header

syntax: vardump.send_content_type_header = fase

default: true

true: Send the HTTP response header Content-Type: text/html before output the dumps.

false: Will not send the header.

Installation

Luarocks:

luarocks install lua-resty-vardump

Manually:

Download the package from the releases page, then extract the lib/resty directory to the the Lua library directory.

    # nginx.conf
    http {
        lua_package_path "/path/to/lua-lib-dir/?.lua;;";
        ...
    }

Ensure that the system account running your Nginx ''worker'' proceses have enough permission to read the .lua file.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.