Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Simple log viewer
def puts_colored(string, num)
puts "[\e[32m#{num}\e[0m] #{string}"
end
file_name = ARGV[0]
File.open(file_name) do |file|
file.each_line {|line|}
timestamp = File.stat(file_name).mtime
current_line = 0
while true do
sleep(0.1)
current_timestamp = File.stat(file_name).mtime
if timestamp != current_timestamp then
file.each_line do |line|
current_line += 1
puts_colored line, current_line
end
timestamp = current_timestamp
end
end
end
@takuseno

This comment has been minimized.

Show comment
Hide comment
@takuseno

takuseno Dec 18, 2016

Usage

$ ruby logviewer.rb logfile
Owner

takuseno commented Dec 18, 2016

Usage

$ ruby logviewer.rb logfile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment