Class: Qswarm::Connections::Logger

Inherits:
Qswarm::Connection show all
Includes:
DSL
Defined in:
lib/qswarm/connections/logger.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from DSL

#dsl_call, #dsl_load, included

Constructor Details

#initialize(agent, name, args, &block) ⇒ Logger

Returns a new instance of Logger.



8
9
10
11
12
# File 'lib/qswarm/connections/logger.rb', line 8

def initialize(agent, name, args, &block)
  @filename = args[:filename] || '/tmp/qswarm-logger.log'

  super(agent, name, args)
end

Instance Attribute Details

#formatObject (readonly)

Returns the value of attribute format.



6
7
8
# File 'lib/qswarm/connections/logger.rb', line 6

def format
  @format
end

Instance Method Details

#emit(payload) ⇒ Object



14
15
# File 'lib/qswarm/connections/logger.rb', line 14

def emit(payload)
end

#runObject



21
22
23
24
# File 'lib/qswarm/connections/logger.rb', line 21

def run
  @file = File.open(@filename, 'a')
  Qswarm.logger.info "[#{@agent.name.inspect} #{@name.inspect}] Logging to #{@filename}"
end

#sink(args, payload) ⇒ Object



17
18
19
# File 'lib/qswarm/connections/logger.rb', line 17

def sink(args, payload)
  @file.puts payload.raw
end