with_verbosity {httr2} | R Documentation |
Temporarily set verbosity for all requests
Description
with_verbosity()
and local_verbosity()
are useful for debugging httr2
code buried deep inside another package, because they allow you to change
the verbosity even when you don't have access to the request.
Both functions work by temporarily setting the httr2_verbosity
option. You
can also control verbosity by setting the HTTR2_VERBOSITY
environment
variable. This has lower precedence than the option, but can be more easily
changed outside of R.
Usage
with_verbosity(code, verbosity = 1)
local_verbosity(verbosity, env = caller_env())
Arguments
code |
Code to execture |
verbosity |
How much information to print? This is a wrapper
around
Use |
env |
Environment to use for scoping changes. |
Value
with_verbosity()
returns the result of evaluating code
.
local_verbosity()
is called for its side-effect and invisibly returns
the previous value of the option.
Examples
fun <- function() {
request("https://httr2.r-lib.org") |> req_perform()
}
with_verbosity(fun())
fun <- function() {
local_verbosity(2)
# someotherpackage::fun()
}