Class: EcsFormatter
- Inherits:
-
Object
- Object
- EcsFormatter
- Defined in:
- lib/ecs_log_rails/ecs_formatter.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#ecs_data ⇒ Object
readonly
Returns the value of attribute ecs_data.
-
#service_env ⇒ Object
readonly
Returns the value of attribute service_env.
-
#service_name ⇒ Object
readonly
Returns the value of attribute service_name.
-
#service_type ⇒ Object
readonly
Returns the value of attribute service_type.
Instance Method Summary collapse
- #call(data) ⇒ Object
-
#initialize(service_name:, service_type:, service_env:) ⇒ EcsFormatter
constructor
A new instance of EcsFormatter.
Constructor Details
#initialize(service_name:, service_type:, service_env:) ⇒ EcsFormatter
Returns a new instance of EcsFormatter.
6 7 8 9 10 |
# File 'lib/ecs_log_rails/ecs_formatter.rb', line 6 def initialize(service_name:, service_type:, service_env:) @service_name = service_name @service_env = service_env @service_type = service_type end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
4 5 6 |
# File 'lib/ecs_log_rails/ecs_formatter.rb', line 4 def data @data end |
#ecs_data ⇒ Object (readonly)
Returns the value of attribute ecs_data.
4 5 6 |
# File 'lib/ecs_log_rails/ecs_formatter.rb', line 4 def ecs_data @ecs_data end |
#service_env ⇒ Object (readonly)
Returns the value of attribute service_env.
4 5 6 |
# File 'lib/ecs_log_rails/ecs_formatter.rb', line 4 def service_env @service_env end |
#service_name ⇒ Object (readonly)
Returns the value of attribute service_name.
4 5 6 |
# File 'lib/ecs_log_rails/ecs_formatter.rb', line 4 def service_name @service_name end |
#service_type ⇒ Object (readonly)
Returns the value of attribute service_type.
4 5 6 |
# File 'lib/ecs_log_rails/ecs_formatter.rb', line 4 def service_type @service_type end |
Instance Method Details
#call(data) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/ecs_log_rails/ecs_formatter.rb', line 12 def call(data) @data = data generate_ecs event = LogStash::Event.new(deep_compact(ecs_data)) event.to_json end |