Class: GreenLog::JsonWriter

Inherits:
Object
  • Object
show all
Defined in:
lib/green_log/json_writer.rb

Overview

A JSON-formated log.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dest) ⇒ JsonWriter

Returns a new instance of JsonWriter.



12
13
14
# File 'lib/green_log/json_writer.rb', line 12

def initialize(dest)
  @dest = dest
end

Instance Attribute Details

#destObject (readonly)

Returns the value of attribute dest.



16
17
18
# File 'lib/green_log/json_writer.rb', line 16

def dest
  @dest
end

Instance Method Details

#<<(entry) ⇒ Object

Raises:

  • (ArgumentError)


18
19
20
21
22
# File 'lib/green_log/json_writer.rb', line 18

def <<(entry)
  raise ArgumentError, "GreenLog::Entry expected" unless entry.is_a?(GreenLog::Entry)

  dest << JSON.dump(entry_details(entry)) + "\n"
end