Class: Mixlib::Log::Child

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/mixlib/log/child.rb

Constant Summary

Constants included from Logging

Logging::LEVELS, Logging::LEVEL_NAMES, Logging::SEV_LABEL, Logging::TRACE

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logging

#pass, #to_label

Constructor Details

#initialize(parent, metadata = {}) ⇒ Child

Returns a new instance of Child.



26
27
28
29
# File 'lib/mixlib/log/child.rb', line 26

def initialize(parent,  = {})
  @parent = parent
  @metadata = 
end

Instance Attribute Details

#metadataObject

Returns the value of attribute metadata.



25
26
27
# File 'lib/mixlib/log/child.rb', line 25

def 
  @metadata
end

#parentObject (readonly)

Returns the value of attribute parent.



24
25
26
# File 'lib/mixlib/log/child.rb', line 24

def parent
  @parent
end

Instance Method Details

#add(severity, message = nil, progname = nil, data: {}, &block) ⇒ Object



45
46
47
48
# File 'lib/mixlib/log/child.rb', line 45

def add(severity, message = nil, progname = nil, data: {}, &block)
  data = .merge(data) if data.is_a?(Hash)
  parent.send(:pass, severity, message, progname, data: data, &block)
end

#levelObject



31
32
33
# File 'lib/mixlib/log/child.rb', line 31

def level
  parent.level
end

#with_child(metadata = {}) ⇒ Object



50
51
52
53
54
55
56
57
# File 'lib/mixlib/log/child.rb', line 50

def with_child( = {})
  child = Child.new(self, )
  if block_given?
    yield child
  else
    child
  end
end