dry-rb / dry-core

A toolset of small support modules used throughout the @dry-rb & @rom-rb ecosystems
https://dry-rb.org/gems/dry-core/
MIT License
170 stars 33 forks source link

Allow printing frame info on warn #52

Closed waiting-for-dev closed 3 years ago

waiting-for-dev commented 3 years ago

A new uplevel can be given on Dry::Core::Deprecations.warn && Dry::Core::Deprecations.announce to print information of the given caller frame. E.g.:


irb(main):001:0> require 'dry/core/deprecations'
=> true
irb(main):002:1* class A
irb(main):003:2*   def a
irb(main):004:2*     Dry::Core::Deprecations.warn('a is deprecated', uplevel: 1)
irb(main):005:1*   end
irb(main):006:1* end
=> :a
irb(main):007:0* A.new.a
/home/root/bin/console:7:in `<main>' [deprecated] a is deprecated
=> true
``