Class: Cyclid::API::Plugins::Log

Inherits:
Action show all
Defined in:
app/cyclid/plugins/action/log.rb

Overview

“Log” plugin; will always succeed. Simply emits a message to the log.

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Action

human_name, #prepare

Methods inherited from Base

author, config?, config_schema, default_config, get_config, homepage, human_name, license, register_plugin, set_config, update_config, version

Constructor Details

#initialize(args = {}) ⇒ Log

Returns a new instance of Log.



24
25
26
27
28
29
30
31
# File 'app/cyclid/plugins/action/log.rb', line 24

def initialize(args = {})
  args.symbolize_keys!

  # There must be a message to log.
  raise 'a log action requires a message' unless args.include? :message

  @message = args[:message]
end

Class Method Details

.metadataObject

Plugin metadata



40
41
42
43
44
45
# File 'app/cyclid/plugins/action/log.rb', line 40

def self.
  super.merge!(version: Cyclid::Api::VERSION,
               license: 'Apache-2.0',
               author: 'Liqwyd Ltd.',
               homepage: 'http://docs.cyclid.io')
end

Instance Method Details

#perform(log) ⇒ Object

Write the log message, with the context data interpolated



34
35
36
37
# File 'app/cyclid/plugins/action/log.rb', line 34

def perform(log)
  log.write("#{@message ** @ctx}\n")
  true
end