You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm writing a script that'll tail a file and email me the changes to the file once a minute (if there are any). Right now, FileWatch::Tail splits new data by line. I'd like to add an open to FileWatch::Tail called :split_lines that gives you the option of splitting lines or not. It would default to true to keep existing behavior. It'd be something like this:
diff --git a/lib/filewatch/tail.rb b/lib/filewatch/tail.rb
index 0bce046..7424ac8 100644
--- a/lib/filewatch/tail.rb
+++ b/lib/filewatch/tail.rb
@@ -32,6 +32,7 @@ module FileWatch
:stat_interval => 1,
:discover_interval => 5,
:exclude => [],
+ :split_lines => true
}.merge(opts)
@watch.exclude(@opts[:exclude])
@@ -138,8 +139,12 @@ module FileWatch
begin
data = @files[path].sysread(4096)
changed = true
- @buffers[path].extract(data).each do |line|
- yield(path, line)
+ if @opts[:split_lines]
+ @buffers[path].extract(data).each do |line|
+ yield(path, line)
+ end
+ else
+ yield(path, data)
end
@sincedb[@statcache[path]] = @files[path].pos
I'd be happy to issue a pull request for that. I can also write tests for it to make sure that it doesn't break anything. If I do that, should I just use mintiest like you use on logstash?
The text was updated successfully, but these errors were encountered:
I'm writing a script that'll tail a file and email me the changes to the file once a minute (if there are any). Right now, FileWatch::Tail splits new data by line. I'd like to add an open to FileWatch::Tail called :split_lines that gives you the option of splitting lines or not. It would default to true to keep existing behavior. It'd be something like this:
I'd be happy to issue a pull request for that. I can also write tests for it to make sure that it doesn't break anything. If I do that, should I just use mintiest like you use on logstash?
The text was updated successfully, but these errors were encountered: