Forum: Ruby Log file

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Sam C. (Guest)
on 2007-01-27 04:31
How do I log the user inputs from my program to a text file? I've looked
on the web for this, and I can't find it...

Erik V. (Guest)
on 2007-01-27 18:48
(Received via mailing list)
Something like this?"user_output.txt", "w") do |f|
   while line = gets
     f.puts line

(Sorry, couldn't resist... ;])

Erik V. -
Jon Egil S. (Guest)
on 2007-01-27 22:13
(Received via mailing list)
A simple solution could be to use 'simplelog'.

c:\> gem search simplelog
simplelog (0.2.2)
    The simplest logger ever. Just require 'simplelog' and all puts
    statements are logged to .txt as well as shown on screen.

Meaning that whenever your program uses puts it's shown on screen as
you're used to, but it's also logged to a logfile.

All the best
This topic is locked and can not be replied to.