lib/suricata/logfile.rb in suricata-0.2.1 vs lib/suricata/logfile.rb in suricata-0.3.1
- old
+ new
@@ -39,16 +39,18 @@
attr_reader :file, :line
# constructor
# @param [String] logfile path and filename of the logfile
# @param [Boolean] autoopen calls open if true(default: true)
-def initialize(logfile,autoopen=true)
+def initialize(logfile,autoopen=true,file=nil)
@logfile = logfile
@parser = Suricata::Fast.new
if autoopen == true
open
+ else
+ @file = file if not file.nil?
end
end
# this method calls parser.parse(string)
# @param [String] string logfile-entry to parse
@@ -87,9 +89,16 @@
end
end
end
# this method reads a line of the logfile
+#
+# @example readline with a block
+# log = Suricata::Logfile.new("misc/fast.log")
+# log.readline do |n|
+# puts n
+# end
+#
# @return [String] line current logfile entry
# @return [Boolean] false when EOF reached
# @yieldparam [String] @line current logfile entry
def readline
begin