https://github.com/wlingze/icecream-lua
Never use print() to debug again. (lua)
https://github.com/wlingze/icecream-lua
debug debugging-tools lua print
Last synced: 4 months ago
JSON representation
Never use print() to debug again. (lua)
- Host: GitHub
- URL: https://github.com/wlingze/icecream-lua
- Owner: wlingze
- Created: 2020-12-12T04:14:32.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2025-02-06T06:14:21.000Z (12 months ago)
- Last Synced: 2025-08-25T07:32:17.153Z (5 months ago)
- Topics: debug, debugging-tools, lua, print
- Language: Lua
- Homepage:
- Size: 12.7 KB
- Stars: 25
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# IceCream-lua
Never use print() to debug again. (lua)
lua version of [IceCream](https://github.com/gruns/icecream).
## install
```sh
luarocks install icecream-lua
```
## use
import module:
```lua
local ic = require("icecream")
```
just use ic() to print information
**The example of printing variables**
```lua
a = 10
ic(a)
local x = 1
local y = 2
ic(x,y)
```
output `ic| a = 1` and `ic| x = 1, y = 1`
**The example of printing function**
```lua
local function fun1(a)
return a + 1
end
ic(fun1(22))
```
output `ic| fun1(22) = 23`
**The example when there are no parameters**
```lua
ic()
```
output: `ic| ` + filename + line + function, like this: `ic| /home/wlz/gh/icecream-lua/main.lua:37: in local 'testNoArg'`
**The example when there is no variable name**
```lua
ic(1, 2)
```
output: `ic| 1, 2`
**The example of display line number**
```lua
ic(x,y)
-- ic| x = 1, y = 1
ic:SetIsOutPutPosition(true)
ic(x,y)
-- /home/wlz/gh/icecream-lua/main.lua:11: in local 'testPosition'
-- ic| x = 1, y = 1
```
**Example of enabling and disabling print**
```lua
local x = 1
local y = 2
local z = 3
ic:Disable()
ic(x)
ic(y)
ic:Enable()
ic(z)
-- ic| z = 3
```