summaryrefslogtreecommitdiff
path: root/lognotify.rb
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2010-09-28 10:26:02 -0700
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2010-09-28 10:26:02 -0700
commit6ee13289bdf6bdb32f2765e469ea5dabaa6643d7 (patch)
treed51e0d3a1e84e1ee8151506182aa3e6ed0b3813b /lognotify.rb
parent05dfcea4e86766ec090be5190482274ccded9bfb (diff)
downloadlognotify-6ee13289bdf6bdb32f2765e469ea5dabaa6643d7.tar.gz
lognotify-6ee13289bdf6bdb32f2765e469ea5dabaa6643d7.tar.xz
Add code to append new lines to cached log.
Diffstat (limited to 'lognotify.rb')
-rwxr-xr-xlognotify.rb15
1 files changed, 14 insertions, 1 deletions
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