Closed nuest closed 6 years ago
A short update: it actually works with only DEBUGME=inspecter
when setting it as an env var outside of R. Does this clarify anything?
DEBUGME=inspecter R -q -e 'library("inspecter"); inspecter::start()'
> library("inspecter"); inspecter::start()
onLoad: libname: /home/daniel/R/x86_64-pc-linux-gnu-library/3.4 environment: base
<environment: namespace:base>
Attaching package: ‘inspecter’
The following object is masked from ‘package:stats’:
start
start: pkg: R_GlobalEnv
<environment: R_GlobalEnv>
inspecter starting...
inspecter initialize plumber with route definitions from /home/daniel/R/x86_64-pc-linux-gnu-library/3.4/inspecter/api.R +29ms
init: pkg: R_GlobalEnv
<environment: R_GlobalEnv>
inspecter run plumber +201ms
Starting server to listen on port 8091
Debugging is turned on/off when you load your package. So setting the env var after loading it, will not change anything.
Sorry, I don't know what changed, I failed to re-test the combinations of values for DEBUGME
:
> Sys.setenv(DEBUGME = "inspecter")
> library(inspecter)
onLoad: libname: /home/daniel/R/x86_64-pc-linux-gnu-library/3.4 environment: base
<environment: namespace:base>
Attaching package: ‘inspecter’
The following object is masked from ‘package:stats’:
start
> inspecter::start()
start: pkg: R_GlobalEnv
<environment: R_GlobalEnv>
inspecter starting...
inspecter initialize plumber with route definitions from /home/daniel/R/x86_64-pc-linux-gnu-library/3.4/inspecter/api.R +35ms
inspecter run plumber +275ms
Starting server to listen on port 8091
Running the swagger UI at http://127.0.0.1:8091/__swagger__/
Apologies for the back and forth. The problem remains for logs from the file inst/api.R
.
@trestletech can you shed light on how plumber::plumb(file = "inst/api.R")
loads the file, i.e. what environment it should be in?
The runtime and environments for plumber are documented here: https://www.rplumber.io/docs/runtime.html
@trestletech Thanks, that helps. So I could define my routers programmatically instead of using annotations and then set my own environment. This line also explains why logging works when I enable it for the the environment R_GlobalEnv,base
. I tried to fix this by creating a new environment with my package environment as parent and initiating my router with it, but that did not work.
Eventually I switched from annotations to defining my endpoints with pr$handle()
.
Hope this helps other people logging plumber with debugme.
I want to use DEBUG for a plumber application. You can find it here: https://github.com/nuest/o2r-inspecter/tree/debugme-issue-report
I would like to configure the debugging using the package name
inspecter
, but there might be an issue with the environments or with the way my package is set up.To find out more I added logs of the default values used in
debug::debugme()
at three times:.onLoad
start()
- the debug statement, in environmentR_GlobalEnv
This is what I get (without a
DEBUGME
environment variable set):Enabling debugging for all environments does the trick for now:
Any help or ideas appreciated, if this setup is too complex for you to evaluate I can try to work out a minimal reprex.