Open
Description
What
Logging modifies the original hash passed into it.
irb(main):001:0> require 'twiglet/logger'
=> true
irb(main):002:0> require_relative '../app/logging'
=> true
irb(main):003:0> logger = Logging.logger
=> #<Twiglet::Logger:0x000000012b22c118 @service_name="abc", @args={}, @validator=#<Twiglet::Validator:0x000000012b227f50 @schema={"type"=>"object", "required"=>["message"], "properties"=>{"m...
irb(main):004:0> hash = { "message": "hi" }
=> {:message=>"hi"}
irb(main):005:0> hash
=> {:message=>"hi"}
irb(main):006:0> hash["foo"] = "bar"
=> "bar"
irb(main):007:0> hash
=> {:message=>"hi", "foo"=>"bar"}
irb(main):008:0> logger.warn hash
{"ecs":{"version":"1.5.0"},"@timestamp":"2022-10-11T15:20:11.354Z","service":{"name":"abc"},"log":{"level":"warn"},"message":"hi","foo":"bar"}
=> true
irb(main):009:0> hash
=> {:message=>"hi", :foo=>"bar"}
irb(main):010:0>
Why
So that Twiglet doesn't modify things passed to it as no one would expect a logger to have such a side effect.
How
Replicate the code from the "What" section above. Try and see why it causes that. Fix it.
ACs
- Twiglet doesn't modify the hash passed into it anymore
Metadata
Metadata
Assignees
Labels
No labels