Forum: Ruby Log file

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community 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...

Thanks!
Erik V. (Guest)
on 2007-01-27 18:48
(Received via mailing list)
Something like this?

 File.open("user_output.txt", "w") do |f|
   while line = gets
     f.puts line
   end
 end

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

gegroet,
Erik V. - http://www.erikveen.dds.nl/
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.

http://rubyforge.org/projects/backofficegems/

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