lib/lo_gspot/output/file.rb in logspot-0.3.0 vs lib/lo_gspot/output/file.rb in logspot-0.4.0
- old
+ new
@@ -1,19 +1,25 @@
class LoGspot::Output::File
- def initialize(file_name)
- FileUtils.mkdir_p(File.dirname(file_name))
- @file = File.open(file_name, 'a')
+ def initialize(arg)
+ if arg.is_a?(String)
+ @physical = true
+ FileUtils.mkdir_p(File.dirname(arg))
+ @file = File.open(arg, 'a')
+ else
+ @physical = false
+ @file = arg
+ end
end
def puts(data)
file.puts(data[:message])
file.flush
end
def finalize
- @file.close
+ file.close if physical
end
private
- attr_reader :file
+ attr_reader :file, :physical
end