Skip to content

How to call certain functions only when log level is DEBUG in plugin? #13474

Closed Answered by bungle
amitonlentra asked this question in Help
Discussion options

You must be logged in to vote

You can use:

if kong.configuration.log_level == "debug" then
  ...
end

The env vars with nginx are only available on init phase, but not with workers. You can also place os.getenv on module level of your handler.lua as handlers are loaded on init phase. But I think it is better to use above.

You obviously don't need to wrap any ngx.log or kong.log.debug with that.

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@amitonlentra
Comment options

Answer selected by amitonlentra
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
pending author feedback Waiting for the issue author to get back to a maintainer with findings, more details, etc...
3 participants