> I'd love a patch for that, though. Someone else requested a way to
> redirect the output via a commandline switch, so a patch would help a
> bunch to make that happen.
I hacked around Capistrano to achieve that, which means adding
functions to the Configuration class. The solution has 2 parts: first
the capfixlog.rb file, which you should put on the same directory with
your 'capfile'. The other is the simple change in the capfile. You
choose the log filename in the capfile -- I guess this can be easily
given from the command line using the following line:
log "#{ENV['LOGFILE']}"
Note that my implementation sends the log BOTH to stdout and to the
given file (like unix 'tee'). I find it useful, but you can change it
(see the code of the "log" method).
Here's the thing:
----------------------------------------------------
## caplogfix.rb
module Capistrano
class MultiWriters
Writer = Struct.new(:outstream, :needs_close)
def initialize(f = nil)
@writers = []
add(f) if f
end
def add(f)
if f.respond_to?(:puts)
# This is an IO object
@writers << Writer.new(f, false)
else
@writers << Writer.new(File.open(f, "a"), true)
end
end
def close
@writers.each { |w| w.outstream.close if w.needs_close }
end
def print(*args)
@writers.each { |w| w.outstream.print(*args) }
end
def puts(*args)
@writers.each { |w| w.outstream.puts(*args) }
end
def write(*args)
@writers.each { |w| w.outstream.write(*args) }
end
end
class Configuration
#
# Add a log output
#
def log(filename)
@logdevice ||= MultiWriters.new(STDOUT)
@logdevice.add(filename)
save_level = @logger.level
@logger.close
@logger = Logger.new(:output => @logdevice)
@logger.level = save_level
@logger.info("Capistrano logging starts:
#{Time.now.utc.iso8601}")
end
end
end
----------------------------------------------------
## capfile
require 'caplogfix'
set :application, "appname"
log "#{application}-cap.log"
# from now on actions are logged to the file (and to STDOUT)
#...
# You can add another "log" statement and then the log will be sent
also to that file.
----------------------------------------------------
Enjoy,
Dubek.
--~--~---------~--~----~------------~-------~--~----~
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/capistrano
-~----------~----~----~----~------~----~------~--~---