Class: RShade::Formatter::Stack::Json
- Defined in:
- lib/rshade/formatter/stack/json.rb
Instance Attribute Summary collapse
-
#filepath ⇒ Object
readonly
Returns the value of attribute filepath.
-
#pretty ⇒ Object
readonly
Returns the value of attribute pretty.
-
#variable_serializer ⇒ Object
readonly
Returns the value of attribute variable_serializer.
Instance Method Summary collapse
- #call(stack_frames, variable_serializer: nil) ⇒ Object
-
#initialize(filepath:, pretty: false) ⇒ Json
constructor
A new instance of Json.
Constructor Details
#initialize(filepath:, pretty: false) ⇒ Json
Returns a new instance of Json.
9 10 11 12 |
# File 'lib/rshade/formatter/stack/json.rb', line 9 def initialize(filepath:, pretty: false) @filepath = filepath @pretty = pretty end |
Instance Attribute Details
#filepath ⇒ Object (readonly)
Returns the value of attribute filepath.
7 8 9 |
# File 'lib/rshade/formatter/stack/json.rb', line 7 def filepath @filepath end |
#pretty ⇒ Object (readonly)
Returns the value of attribute pretty.
7 8 9 |
# File 'lib/rshade/formatter/stack/json.rb', line 7 def pretty @pretty end |
#variable_serializer ⇒ Object (readonly)
Returns the value of attribute variable_serializer.
7 8 9 |
# File 'lib/rshade/formatter/stack/json.rb', line 7 def variable_serializer @variable_serializer end |
Instance Method Details
#call(stack_frames, variable_serializer: nil) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rshade/formatter/stack/json.rb', line 15 def call(stack_frames, variable_serializer: nil) payload = stack_frames.map.with_index do |frame, idx| serialize(idx, frame, variable_serializer) end File.open(filepath, 'a+') do |file| record = { time: Time.now.getutc, thread_id: Thread.current, thread_list: Thread.list, frames: payload } file.puts(convert_to_json(record, pretty)) end end |