Class: Qswarm::Connections::Logger
- Inherits:
-
Qswarm::Connection
- Object
- Qswarm::Connection
- Qswarm::Connections::Logger
- Includes:
- DSL
- Defined in:
- lib/qswarm/connections/logger.rb
Instance Attribute Summary collapse
-
#format ⇒ Object
readonly
Returns the value of attribute format.
Instance Method Summary collapse
- #emit(payload) ⇒ Object
-
#initialize(agent, name, args, &block) ⇒ Logger
constructor
A new instance of Logger.
- #run ⇒ Object
- #sink(args, payload) ⇒ Object
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
#format ⇒ Object (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 |
#run ⇒ Object
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 |