|
|
|
|
@ -43,16 +43,16 @@ log.debug("request opts:", utils.dump(opts)) |
|
|
|
|
## Controlling what is shown |
|
|
|
|
|
|
|
|
|
Log output goes to **standard error**, and which levels are shown is set by the |
|
|
|
|
`RUST_LOG` environment variable. By default only `WARN` and `ERROR` appear: |
|
|
|
|
`LUNA_LOG` environment variable. By default only `WARN` and `ERROR` appear: |
|
|
|
|
|
|
|
|
|
```sh |
|
|
|
|
luna script.lua # default: warnings and errors only |
|
|
|
|
RUST_LOG=info luna script.lua # info and above |
|
|
|
|
RUST_LOG=debug luna script.lua # debug and above |
|
|
|
|
RUST_LOG=trace luna script.lua # everything |
|
|
|
|
LUNA_LOG=info luna script.lua # info and above |
|
|
|
|
LUNA_LOG=debug luna script.lua # debug and above |
|
|
|
|
LUNA_LOG=trace luna script.lua # everything |
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
A level shows itself and everything more severe — `RUST_LOG=info` includes |
|
|
|
|
A level shows itself and everything more severe — `LUNA_LOG=info` includes |
|
|
|
|
`info`, `warn`, and `error` but not `debug` or `trace`. Messages below the active |
|
|
|
|
level are discarded cheaply, so leaving `log.debug` calls in place costs almost |
|
|
|
|
nothing when they are not enabled. |
|
|
|
|
@ -71,7 +71,7 @@ turn up or down without editing the script. |
|
|
|
|
|
|
|
|
|
```lua |
|
|
|
|
local rows = con:query("SELECT * FROM users") |
|
|
|
|
log.info("fetched", #rows, "rows") -- diagnostic; hidden unless RUST_LOG=info |
|
|
|
|
log.info("fetched", #rows, "rows") -- diagnostic; hidden unless LUNA_LOG=info |
|
|
|
|
for _, r in ipairs(rows) do |
|
|
|
|
print(r.name) -- the actual result |
|
|
|
|
end |
|
|
|
|
@ -80,7 +80,7 @@ end |
|
|
|
|
## Notes |
|
|
|
|
|
|
|
|
|
- **Always loaded.** No `require`; `log` is a global in every script. |
|
|
|
|
- **Quiet by default.** With no `RUST_LOG` set, only `warn`/`error` are emitted, |
|
|
|
|
- **Quiet by default.** With no `LUNA_LOG` set, only `warn`/`error` are emitted, |
|
|
|
|
so `info`/`debug`/`trace` are silent until you opt in. |
|
|
|
|
- **Arguments are stringified like `print`.** Multiple arguments are joined with |
|
|
|
|
tabs; tables print as their address, so use `utils.dump` for contents. |
|
|
|
|
|