Feature #20864
Updated by ioquatix (Samuel Williams) 1 day ago
## Background `Kernel#warn` is extremely useful, especially because there useful. It is a mechanism for loggers to redirect warnings using the `Warning` module. Currently, it is possible to include some details about the current caller using `uplevel` for the current call stack. But it is not possible to include details about exceptions. errors. I'd like to propose another extension to log errors. ```ruby begin ... # some work rescue => error warn "Something went wrong!", exception: "An error occurred!", error: error end ``` Because of this, trying to emit detailed structured logs from `warn` is tricky. ## Proposal I'd like to propose another extension to log errors. We Such a feature would allow `warn(..., **options)` to accept all options, and forward them all to `Warning.warn`. This would allow us to add more details to warnings and emit structured logs log errors using `Warning.warn`. A simple example of the proposed interface: ```ruby module Kernel def warn(*arguments, uplevel: ..., **options) # Existing processing of arguments -> message ::Warning.warn(message, **options) end end ``` a standard interface. I don't have an opinion about the implementation, but I wanted to get feedback on the interface.