From: Simon Strandgaard <neoneye / gmail.com>
Subject: logging with rake
Date: Fri, 27 Jan 2006 06:11:43 +0900

> Howto capture stdout + stderr from jobs invoked with rake?
> 
> 
> I run rake from cron. I have a

cd /path/to/backup; rake 2>&1 >> /log/handybackup.log

And `tail -f /log/handybackup.log' will help you.
I use GNU Screen and have many `tail -f' windows in Screen.

> def log(msg)
> 	str = Time.now.to_s + ":  " + msg + "\n"
> 	file = $settings['logfile']
> 	File.open(file, 'a+') {|f| f.write str }
> end

Using shell redirection makes the log method simple.

def log(msg)
	str = Time.now.to_s + ":  " + msg + "\n"
        print str
end


> desc "creates a hotcopy backup of the repository."
> task :backup => [:clean] do

I think the `backup' task shold be splitted into some small tasks.
--
rubikitch
http://www.rubyist.net/~rubikitch/