From 6ee13289bdf6bdb32f2765e469ea5dabaa6643d7 Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Tue, 28 Sep 2010 10:26:02 -0700 Subject: Add code to append new lines to cached log. --- lognotify.rb | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'lognotify.rb') diff --git a/lognotify.rb b/lognotify.rb index 0b6b030..3e26b5b 100755 --- a/lognotify.rb +++ b/lognotify.rb @@ -49,6 +49,15 @@ def retrieve_lines path, lines, hostname return %x[ssh #{hostname} "#{command}"] end +# Append new lines to cached log. +def append_lines identifier, lines + filepath = File.expand_path(CACHE_DIR + '/' + identifier + '.log') + file = File.open(filepath, 'a') + + file.print lines + file.close +end + # Output all messages immediately, as opposed to buffering. STDOUT.sync = true @@ -65,6 +74,10 @@ ARGV.each do |identifier| puts 'Done' puts '* Number of new lines: ' + newlines.lines.count.to_s - puts + + print '* Appending new lines to cached log... ' + append_lines(identifier, newlines) + puts 'Done' + puts newlines end -- cgit v1.2.3-70-g09d2