module Dry::Core::Deprecations
def [](tag)
def [](tag) Tagged.new(tag) end
def announce(name, msg, tag: nil)
-
msg
(String
) -- additional message usually containing upgrade instructions -
name
(Object
) -- what is deprecated
def announce(name, msg, tag: nil) warn(deprecation_message(name, msg), tag: tag) end
def deprecated_name_message(old, new = nil, msg = nil)
- Api: - private
def deprecated_name_message(old, new = nil, msg = nil) if new deprecation_message(old, <<-MSG) Please use #{new} instead. #{msg} MSG else deprecation_message(old, msg) end end
def deprecation_message(name, msg)
- Api: - private
def deprecation_message(name, msg) <<-MSG #{ name } is deprecated and will be removed in the next major version #{ msg } MSG end
def logger(output = $stderr)
-
(Logger)
-
Parameters:
-
output
(IO
) -- output stream
def logger(output = $stderr) if defined?(@logger) @logger else set_logger!(output) end end
def set_logger!(output = $stderr)
- Api: - public
Parameters:
-
logger
(#warn
) -- -
output
(IO
) -- Stream for messages
Overloads:
-
set_logger!(logger)
-
set_logger!
-
set_logger!(output)
def set_logger!(output = $stderr) if output.respond_to?(:warn) @logger = output else @logger = Logger.new(output).tap do |logger| logger.formatter = proc { |_, _, _, msg| "#{ msg }\n" } end end end
def warn(msg, tag: nil)
-
msg
(String
) -- Warning string
def warn(msg, tag: nil) tagged = "[#{tag || 'deprecated'}] #{msg.gsub(/^\s+/, '')}" logger.warn(tagged) end