Hi Eric,
Whilst it's not Rubyish, it is `unixish` - Capistrano is a tool for
deploying, and unix has a great many tools already for recording and logging
streams. (tee(1) and script(1) as well as the output redirection tips I
already mentioned)
Whilst there's something to be said for having an all-in-one solution; I
don't believe that this style of logging belongs in Capistrano.
There's always the notion that we should use a more compliant Logger
implementation, so that people can swap them out, and some people have had
success hacking the logger simply to colourise output.
In your earlier post you mentioned that you'd like to output it, and see it
- actually that's what tee(1) is for; it can redirect the output, and
display it to the screen.
So we get to maintain an awesome deployment tool, and you get to build an
awesome logging tool; all built on top of the handy things that unix has
given us for free for the last 20 years!
It's pretty trivial to do something like `campcap deploy` where campcap is
an alias or function you can configure in your shell; here's an example in
bash (add to the appropriate ~/.bash_profile or something…)
#
# Simple utility function to
# always pipe the output from
# Capistrano to the notify_campfire script
#
function campcap {
echo "Running: cap ${1} | notify_campfire";
`cap ${1} | notify_campfire`
}
Usage would then be something like:
campcap deploy
campcap deploy:migrations
As I already alluded to, a simple script to wait until STDIN/OUT are done
streaming, then push the file to Campfire would be trivial (actually,
awesome idea would be to use your Github API keys to push it to a Gist, and
then announce the link in Campfire)
If you want to pursue that route, I'd be more than happy to assist…
HTH
- Lee Hambley
On 13 April 2010 18:03, Eric Lubow <[email protected]> wrote:
> Lee,
>
> Thanks, I'll give this a try later today.
>
> Essentially what I was hoping for was something along the lines of:
> http://pastie.org/917637. Please bear in mind that I am just learning Ruby
> so what I put there was likely closer to pseudocode than actual code.
>
> I wanted to be able to add that to my Capfile and then when I do a cap
> deploy, it will work. I don't know Capistrano to know if there is anything
> I can hook into.
>
> Ultimately, what I have been doing is similar to what you suggested with
> pipes. It just seemed a bit kludgy and not really Rubyish.
>
> Is what I'm looking to do possible in the Capfile without hacking up the
> Capistrano code?
>
> -e
>
> On Tue, Apr 13, 2010 at 3:52 AM, Lee Hambley <[email protected]>wrote:
>
>> Hi,
>>
>> I recommend not messing with the Capistrano logger, Instead use what unix
>> gives you and use pipes:
>>
>> $ cap deploy | my_logger.rb
>>
>> Where your logger reads STDIN and STDOUT and both records, and pipes it
>> back to the appropriate stream.
>>
>> For an alternative, the Engineyard cap recipies [
>> http://github.com/engineyard/eycap ] have a logger [
>> http://github.com/engineyard/eycap/blob/master/lib/eycap/lib/ey_logger.rb ]
>> – this might be a useful reference if you do need to edit the code, but I
>> recommend not doing.
>>
>> -- Lee Hambley
>>
>> Twitter: @leehambley | @capistranorb
>>
>>
>>
>> On 13 April 2010 05:15, Eric Lubow <[email protected]> wrote:
>>
>>> I have a Capistrano deploy file (Capfile) that is rather large,
>>> contains a few namespaces and generally has a lot of information
>>> already in it. My ultimate goal is, using the Tinder gem, paste the
>>> output of the entire deployment into Campfire. I have Tinder setup
>>> properly already.
>>>
>>> I looked into using the Capistrano capture method, but that only works
>>> for the first host. Additionally that would be a lot of work to go
>>> through and add something like:
>>>
>>> output << capture 'foocommand'
>>>
>>> Specifically, I am looking to capture the output of any deployment
>>> from that file into a variable (in addition to putting it to STDOUT so
>>> I can see it), then pass that output in the variable into a function
>>> called notify_campfire. Since the notify_campfire function is getting
>>> called at the end of a task (every task regardless of the namespace),
>>> it should have the task name available to it and the output (which is
>>> stored in that output variable). Any thoughts on how to accomplish
>>> this would be greatly appreciated.
>>>
>>> It would be great if there was a patch that I could add to capture the
>>> entire output (to $stdout or $stderr) and then at the end of the task
>>> do this:
>>> room.speak "Deploying #{task} ..."
>>> room.paste "#{msg}\n"
>>> room.speak "Completed #{task}"
>>>
>>> Is this possible?
>>>
>>> (Full disclosure): I have already posted this question on
>>> StackOverflow (http://stackoverflow.com/questions/2611628/redirect-
>>> output-of-capistrano<http://stackoverflow.com/questions/2611628/redirect-output-of-capistrano>)
>>> , but haven't yet received an answer.
>>>
>>> --
>>> * You received this message because you are subscribed to the Google
>>> Groups "Capistrano" group.
>>> * To post to this group, send email to [email protected]
>>> * To unsubscribe from this group, send email to
>>> [email protected]<capistrano%[email protected]>For
>>> more options, visit this group at
>>> http://groups.google.com/group/capistrano?hl=en
>>>
>>> To unsubscribe, reply using "remove me" as the subject.
>>>
>>
>> --
>> * You received this message because you are subscribed to the Google
>> Groups "Capistrano" group.
>> * To post to this group, send email to [email protected]
>> * To unsubscribe from this group, send email to
>> [email protected]<capistrano%[email protected]>For
>> more options, visit this group at
>> http://groups.google.com/group/capistrano?hl=en
>>
>
> --
> * You received this message because you are subscribed to the Google Groups
> "Capistrano" group.
> * To post to this group, send email to [email protected]
> * To unsubscribe from this group, send email to
> [email protected]<capistrano%[email protected]>For
> more options, visit this group at
> http://groups.google.com/group/capistrano?hl=en
>
--
* You received this message because you are subscribed to the Google Groups
"Capistrano" group.
* To post to this group, send email to [email protected]
* To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/capistrano?hl=en