Sha256: e94754666ff9edd8a50e926411414e6c5876758a57d4d2d7c22bc01cab136b37

Contents?: true

Size: 959 Bytes

Versions: 3

Compression:

Stored size: 959 Bytes

Contents

# Deprecated, do not use in new code, to be removed.
class Gelf
  def deprecate(instead)
    Kernel.caller.first =~ /:in `(.+)'$/
    warn "Gelf##{$1} is deprecated. Use #{instead} instead."
  end

  attr_reader :notifier, :message

  def initialize(hostname, port)
    deprecate('GELF::Notifier.new(hostname, port) and GELF::Message.new')
    @notifier = GELF::Notifier.new(hostname, port)
    @message = {}
  end

  # bizarre, but Gelf did this...
  def send
    deprecate('GELF::Notifier#notify(message)')
    @notifier.notify(@message)
  end

  [:short_message, :full_message, :level, :host, :line, :file].each do |attribute|
    define_method attribute do
      deprecate("GELF::Message##{attribute}")
      @message[attribute]
    end

    define_method "#{attribute}=" do |value|
      deprecate("GELF::Message##{attribute} = value")
      @message[attribute] = value
    end
  end

  def add_additional(key, value)
    @message[key] = value
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gelf-1.1.0.beta3 lib/gelf/deprecations.rb
gelf-1.1.0.beta2 lib/gelf/deprecations.rb
gelf-1.1.0.beta1 lib/gelf/deprecations.rb