Class: Euston::Daemons::Pipeline::CommandLogger::Log
- Inherits:
-
Object
- Object
- Euston::Daemons::Pipeline::CommandLogger::Log
- Defined in:
- lib/euston-daemons/pipeline/lib/command_logger/log.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(mongodb) ⇒ Log
constructor
A new instance of Log.
- #write_command(command) ⇒ Object
Constructor Details
#initialize(mongodb) ⇒ Log
Returns a new instance of Log.
6 7 8 9 10 11 |
# File 'lib/euston-daemons/pipeline/lib/command_logger/log.rb', line 6 def initialize mongodb @name = 'command_log' mongodb.create_collection @name unless mongodb.collection_names.include? @name @collection = mongodb.collection @name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
13 14 15 |
# File 'lib/euston-daemons/pipeline/lib/command_logger/log.rb', line 13 def name @name end |
Instance Method Details
#write_command(command) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/euston-daemons/pipeline/lib/command_logger/log.rb', line 15 def write_command command = Time.now.to_f doc = { 'command_id' => command[:headers][:id], 'type' => command[:headers][:type], 'version' => command[:headers][:version], 'timestamp' => , 'timestamp_for_humans' => Time.at(), 'json' => ActiveSupport::JSON.encode(command) } @collection.insert doc end |