Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dnsdist: add getVerbose() function #11637

Merged
merged 2 commits into from
May 23, 2022
Merged

Conversation

Habbie
Copy link
Member

@Habbie Habbie commented May 23, 2022

Short description

This allows Lua code to entirely skip verbose log calls if verbose logging is disabled.

Checklist

I have:

  • read the CONTRIBUTING.md document
  • compiled this code
  • tested this code
  • included documentation (including possible behaviour changes)
  • documented the code
  • added or modified regression test(s)
  • added or modified unit test(s)
  • checked that this code was merged to master

@Habbie Habbie added this to the dnsdist-1.8.0 milestone May 23, 2022
@Habbie
Copy link
Member Author

Habbie commented May 23, 2022

Example usage:

local g_verbose = getVerbose()

function maintenance()
  g_verbose = getVerbose()
end

local function vfinfolog(...)
  if g_verbose then
    infolog(string.format(...))
  end
end

vfinfolog("we may or may not log this one param1=%s param2=%s", "foo", "bar")

setVerbose(true)
maintenance()

vfinfolog("we definitely log this one param1=%s param2=%s", "foo", "bar")

setVerbose(false)
maintenance()

vfinfolog("this one should be almost free param1=%s param2=%s", "foo", "bar")

Co-authored-by: Remi Gacogne <github@coredump.fr>
@rgacogne rgacogne merged commit 2390788 into PowerDNS:master May 23, 2022
@Habbie Habbie deleted the dnsdist-getverbose branch May 23, 2022 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants