Class: Txray::Runtime::Sink
- Inherits:
-
Object
- Object
- Txray::Runtime::Sink
- Defined in:
- lib/txray/runtime/sink.rb
Defined Under Namespace
Classes: Null
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(path) ⇒ Sink
constructor
A new instance of Sink.
- #write(event) ⇒ Object
Constructor Details
#initialize(path) ⇒ Sink
Returns a new instance of Sink.
12 13 14 |
# File 'lib/txray/runtime/sink.rb', line 12 def initialize(path) @path = path end |
Class Method Details
.build(path) ⇒ Object
8 9 10 |
# File 'lib/txray/runtime/sink.rb', line 8 def self.build(path) path ? new(path) : Null.new end |
Instance Method Details
#write(event) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/txray/runtime/sink.rb', line 16 def write(event) prepare File.open(@path, "a") do |file| file.flock(File::LOCK_EX) file.puts(JSON.generate(event)) end rescue StandardError nil end |