Open kamilzyla opened 2 years ago
Information from @jakubnowicki: R_CONFIG_ACTIVE is a default variable that controls the choice of configuration version (config package), but it is NOT allowed in RStudio Connect. This makes controlling different versions of logging impossible because Rhino uses the default variable
I think this one is a bug or borderline bug.
Updating config.yml
to include:
prod:
rhino_log_level: FATAL
R_CONFIG_ACTIVE
to change the environments.R_CONFIG_ACTIVE
is set to.I think 1. is has a low frequency - if someone can use the default R_CONFIG_ACTIVE
, then chances are they will use it.
However, with 2., I think the frequency is much higher. Most of the apps I saw used a different environment variable to have the full control. This means that there will be a mismatch of variables - {rhino} uses R_CONFIG_ACTIVE
and the app uses something else.
I didn't know about this until recently when I was browsing through {rhino}'s codebase.
I think the solution here is to configure the environment variable name via rhino.yml
and pass it to config::get()
:
https://github.com/Appsilon/rhino/blob/7c6106f8857aa5ab647f22075b006f6191a34bb0/R/app.R#L75
It could fall back to R_CONFIG_ACTIVE
if not set - this way it won't break existing applications.
Alternatives:
rhino::set_log_level()
? The user is in charge.rhino::log
is quite a thin wrapper on logger. Perhaps encouraging users to use {logger} directly would make sense?
Background
In Posit Connect you can set environment variables for each application separately. You cannot set
R_CONFIG_ACTIVE
however - it is configured statically for the whole server usingR.ConfigActive
setting. By default this environment variable is used byconfig::get()
to select the configuration to load.Problem
Internally Rhino calls
config::get()
with default arguments (usingR_CONFIG_ACTIVE
) to readrhino_log_level
andrhino_log_file
settings fromconfig.yml
. If our users decide to use a different environment variable to control which config is loaded (e.g. they callconfig::get(config = Sys.getenv("TARGET_ENV", "default"))
in their code), they will be unable to manage logging settings in the same way.It is still possible to configure logging separately for different applications deployed to the same Posit Connect server (by default we read
RHINO_LOG_LEVEL
andRHINO_LOG_FILE
environment variables) but it can make the configuration more complex and difficult to understand.Notes