Hello,

I'm working on an interesting project using capistrano to propagate a
php app from server to server. I have two things I can do in a fairly
mundane way, but was hoping there was a more elegant solution:


1. In some tasks i want to log some messages, using the name of the
task in the message. I can't seem to figure out how to get at this
programmatically. Something like

[:a, :b, :c].each do |server|
  namespace server do
     task "do_something" do
        log_message(" command #{command} had an issue")
     end
  end
end

I've looked through the cap code and find ways to search for tasks, to
get things like fully_qualified_namespace (which in this case just
reports "a" or "b" etc)

Is there a way to get command to report "a:do_something" by inspecting
something?


2. I need to handle situations where errors come up in the running of
various tasks by showing that error to the user but also logging it to
a file. Currently i've done something like:

config = Capistrano::Configuration.new
config.logger = Capistrano::Logger.new(:output => "./log/
capistrano.log")
config.logger.level = Capistrano::Logger::TRACE

....

begin
  do_a_task
rescue => e
  config.logger.info(log_message("#{server}:deploy",e))
end

I'd love to not have to wrap every task's code in these blocks. Is
there some way i can setup a default rescue? I've trapped various
levels of the code in begin/rescue blocks but it doesn't seem to work
unless its right around the code. (i was thinking something similar to
the rescue_action stuff with rails.)


If I'm going about that the wrong way, and there's an easier way to
just say log all errors here and use this format or callback to format
the message then that's probably a better way, just seems like I need
to do something more manual like i've described above.


Anyway, its an interesting project and I'm thankful to have cap do
what it does for me. If anyone has any tips or thoughts on the above
i'd be most appreciative.

Thanks!

Jack


--~--~---------~--~----~------------~-------~--~----~
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/capistrano
-~----------~----~----~----~------~----~------~--~---

Reply via email to