Class: Datadog::CI::Logs::Component

Inherits:
Object
  • Object
show all
Defined in:
lib/datadog/ci/logs/component.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(enabled:, writer:) ⇒ Component

Returns a new instance of Component.



11
12
13
14
# File 'lib/datadog/ci/logs/component.rb', line 11

def initialize(enabled:, writer:)
  @enabled = enabled && !writer.nil?
  @writer = writer
end

Instance Attribute Details

#enabledObject (readonly)

Returns the value of attribute enabled.



9
10
11
# File 'lib/datadog/ci/logs/component.rb', line 9

def enabled
  @enabled
end

Instance Method Details

#shutdown!Object



25
26
27
# File 'lib/datadog/ci/logs/component.rb', line 25

def shutdown!
  @writer&.stop
end

#write(event) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/datadog/ci/logs/component.rb', line 16

def write(event)
  return unless enabled

  add_common_tags!(event)
  @writer&.write(event)

  nil
end