-
Notifications
You must be signed in to change notification settings - Fork 58
overhaul action levels to log levels #604
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
Comments
Thanks for the issue! Yeah, this should absolutely be done. It's a breaking change like in py-pointblank but the R version has had |
As a first step towards deprecation, without touching too much internal code, I can imagine re-writing action_levels <- function(
+ warn = NULL,
+ error = NULL,
+ critical = NULL,
+ fns = NULL,
+ ...,
warn_at = NULL,
stop_at = NULL,
- notify_at = NULL,
- fns = NULL
+ notify_at = NULL
) {
+ # Gradual argument name deprecation
+ ## Deprecation message
+ if (!missing(warn_at) || !missing(stop_at) || !missing(notify_at)) {
+ cli::cli_inform(
+ c("!" = "Arguments `warn_at`, `stop_at`, and `notify_at` are deprecated.",
+ " " = "Please use `warn`, `error`, and `critical` instead."),
+ .frequency = "always",
+ .frequency_id = "pointblank-action-levels-args-deprecation"
+ )
+ }
+ ## Guard partial matching and redundant args
+ rlang::check_dots_empty()
+ rlang::check_exclusive(warn, warn_at, .require = FALSE)
+ rlang::check_exclusive(error, stop_at, .require = FALSE)
+ rlang::check_exclusive(critical, notify_at, .require = FALSE)
+ ## Resolve names
+ warn <- warn %||% warn_at
+ error <- error %||% stop_at
+ critical <- critical %||% notify_at
+
fns <- normalize_fns_list(fns = fns)
- warn_list <- normalize_fraction_count(warn_at)
- stop_list <- normalize_fraction_count(stop_at)
- notify_list <- normalize_fraction_count(notify_at)
+ warn_list <- normalize_fraction_count(warn)
+ stop_list <- normalize_fraction_count(error)
+ notify_list <- normalize_fraction_count(critical)
# <rest of function> Something like this would ensure backwards compatibility for both positional and named arguments, but throw a deprecation message if matched by name. And while both name variants are active, we'd throw an error if both are redundantly supplied. I'll dig around more for whether a similar problem had been solved more cleanly before! Other than that, |
Action levels are more appropriately described as flags or threshold levels. Align flags with log levels for further downstream actions.
warn_at
->warn
stop_at
->error
notify_at
->critical
Aligns with decisions made in python pointblank. posit-dev/pointblank#69
The text was updated successfully, but these errors were encountered: