Question says all about my requirement, but I'll try to explain in detail.
I have a log file, say development.log
, and like a normal log file as requests are made, this file grows. I want to watch for this file and then if a new line(request) is added to this log file, I want to do something with this new line(say just print it). So everytime a new line is added, it should print in my rails console.
How can I achieve this in Ruby Script?
EDIT: Adding more info
Ex:
If I have a initial log file:
# development.log GET abcd.com POST efgh.com
Now, I will run my ruby script, which will watch this log file for changes.
After 5 seconds the the log file becomes:
# development.log GET abcd.com POST efgh.com GET newdomain.com POST newdomain.com
Now since the log file changed, My ruby console must print these new lines:
# ruby output GET newdomain.com POST newdomain.com