Warning: The Module

1 · Jan Lelis · May 15, 2018, midnight
Starting with Ruby 2.5¹ it is possible to customize the behavior of Kernel#warn through the Warning module. Here is how: def Warning.warn(w) # super calls the original behavior, which is printing to $stderr super "\e[31;1mRUBY WARNING: \e[22m#{w.sub(/warning: /, '')}\e[0m" end # # # # examples warn "test" # => RUBY WARNING: test { a: 1, a: 2 } # => RUBY WARNING: (irb):4: key :a is duplicated and overwritten on line 4 $VERBOSE = true # shows level 2 warnings def a() end def a() end # => ...