Class: Logging::Appenders::Papertrail

Inherits:
Logging::Appender
  • Object
show all
Defined in:
lib/logging/appenders/papertrail.rb

Instance Method Summary collapse

Constructor Details

#initialize(name, opts = {}) ⇒ Papertrail

Returns a new instance of Papertrail.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/logging/appenders/papertrail.rb', line 13

def initialize(name, opts = {})
  ::Logging.init unless ::Logging.initialized?

  @name    = name.to_s
  @closed  = false
  @filters = []
  @mutex   = ReentrantMutex.new

  self.layout   = opts.fetch(:layout, ::Logging::Layouts::Basic.new)
  self.level    = opts.fetch(:level, nil)
  self.encoding = opts.fetch(:encoding, self.encoding)
  self.filters  = opts.fetch(:filters, nil)

  if opts.fetch(:header, true)
    header = @layout.header

    unless header.nil? || header.empty?
      begin
        write(header)
      rescue StandardError => err
        ::Logging.log_internal_error(err)
      end
    end
  end

  ::Logging::Appenders[@name] = self
end

Instance Method Details

#close(*args) ⇒ Object



41
42
43
# File 'lib/logging/appenders/papertrail.rb', line 41

def close(*args)
  super(false)
end