Class: Logging::Appenders::Journald

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Journald.



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

def initialize(name, opts = {})
  opts[:layout] ||= ::Logging::Layouts::Noop.new
  @ident = opts.fetch(:ident, name)
  @mdc = opts.fetch(:mdc, true)
  @ndc = opts.fetch(:ndc, true)
  @facility = Integer(opts.fetch(:facility, -1))
  @extra = opts.fetch(:extra, {})
  @logger_name = opts.fetch(:logger_name, false)
  @map = [
    ::Journald::LOG_DEBUG,
    ::Journald::LOG_INFO,
    ::Journald::LOG_WARNING,
    ::Journald::LOG_ERR,
    ::Journald::LOG_CRIT
  ]
  map = opts.fetch(:map, nil)
  self.map = map unless map.nil?
  @journal = ::Journald::Logger.new(ident, ::Journald::LOG_DEBUG)
  #@journal.sev_threshold = ::Journald::LOG_DEBUG
  super(name, opts)
end

Instance Attribute Details

#extraObject (readonly)

Returns the value of attribute extra.



14
15
16
# File 'lib/logging/appenders/journald.rb', line 14

def extra
  @extra
end

#facilityObject (readonly)

Returns the value of attribute facility.



14
15
16
# File 'lib/logging/appenders/journald.rb', line 14

def facility
  @facility
end

#identObject (readonly)

Returns the value of attribute ident.



14
15
16
# File 'lib/logging/appenders/journald.rb', line 14

def ident
  @ident
end

#journalObject (readonly)

Returns the value of attribute journal.



14
15
16
# File 'lib/logging/appenders/journald.rb', line 14

def journal
  @journal
end

#mdcObject (readonly)

Returns the value of attribute mdc.



14
15
16
# File 'lib/logging/appenders/journald.rb', line 14

def mdc
  @mdc
end

#ndcObject (readonly)

Returns the value of attribute ndc.



14
15
16
# File 'lib/logging/appenders/journald.rb', line 14

def ndc
  @ndc
end

Instance Method Details

#close(*args) ⇒ Object



47
48
49
# File 'lib/logging/appenders/journald.rb', line 47

def close(*args)
  super(false)
end

#map=(levels) ⇒ Object



38
39
40
41
42
43
44
45
# File 'lib/logging/appenders/journald.rb', line 38

def map=(levels)
  map = []
  levels.keys.each do |lvl|
    num = ::Logging.level_num(lvl)
    map[num] = syslog_level_num(levels[lvl])
  end
  @map = map
end