Archive of RubyForge sup-talk mailing list
 help / color / mirror / Atom feed
* [sup-talk] Hints on debugging hooks
@ 2010-10-19  9:18 Shadowfirebird
  2010-10-19 17:31 ` Michael Stapelberg
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Shadowfirebird @ 2010-10-19  9:18 UTC (permalink / raw)
  To: sup-talk

Hi, I'm new to Sup.  (I can code Ruby, a bit, but I'm finding the source hard to read, so configuration is going slower than I would like. It's me, not you...)

Can someone give me some hints on debugging hooks? For example, is there an easy way to get just one message object in the console, so I can play with it?  

Is it true that the before-add-message hook can die silently if my code is bad?  Will wrapping my code in begin ... rescue ... end guarantee that this doesn't happen?

Ta. 

-- 
"All snakes who wish to remain in Ireland will please raise their right hands."
		-- Saint Patrick
_______________________________________________
sup-talk mailing list
sup-talk@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-talk


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [sup-talk] Hints on debugging hooks
  2010-10-19  9:18 [sup-talk] Hints on debugging hooks Shadowfirebird
@ 2010-10-19 17:31 ` Michael Stapelberg
  2010-10-19 18:18 ` Hamish D
  2010-10-20 21:00 ` Shadowfirebird
  2 siblings, 0 replies; 4+ messages in thread
From: Michael Stapelberg @ 2010-10-19 17:31 UTC (permalink / raw)
  To: sup-talk

Hi,

Excerpts from Shadowfirebird's message of 2010-10-19 11:18:03 +0200:
> Can someone give me some hints on debugging hooks? For example, is there an
> easy way to get just one message object in the console, so I can play with
> it?  
Yep, there is:
$ irb1.9.1 -Ilib
>> require 'sup'
>> include Redwood
>> start
>> i = Index.init
>> i.load

If you have some message ID you want to load, you can do so. If you don’t know
which one to load, you could print them all (beware, on a big index, this of
course will be a very long listing):
>> i.each_id { |i| puts i }

To actually load the message:
>> m = i.build_message("201010062050.45778.kern@sibbald.com")

You can then play with the masseg as you like.

> Is it true that the before-add-message hook can die silently if my code is
> bad?  Will wrapping my code in begin ... rescue ... end guarantee that this
> doesn't happen?
Not sure about that. At least in the system log (press ; to open the buffer
manager) it will leave a trace about hooks dying, but I don’t know if it’s
display very obviously when you’re not having an eye on the log.

Best regards,
Michael
_______________________________________________
sup-talk mailing list
sup-talk@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-talk

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [sup-talk] Hints on debugging hooks
  2010-10-19  9:18 [sup-talk] Hints on debugging hooks Shadowfirebird
  2010-10-19 17:31 ` Michael Stapelberg
@ 2010-10-19 18:18 ` Hamish D
  2010-10-20 21:00 ` Shadowfirebird
  2 siblings, 0 replies; 4+ messages in thread
From: Hamish D @ 2010-10-19 18:18 UTC (permalink / raw)
  To: Shadowfirebird; +Cc: sup-talk

> Can someone give me some hints on debugging hooks? For example, is there an easy way to get just one message object in the console, so I can play with it?

For hooks, I tried using debug. So in the before-add-message hook you
could have:

  debug ("message subject is #{message.subj} and is from #{message.from.email}")

Then launch sup with debug on:

  $ SUP_LOG_LEVEL=debug sup

And you will get extra logging, including your hook debug message, in
the log buffer (press ; to see the buffer list).

One thing to watch out for in the message hooks is that the regex is
case sensitive by default. To change that, just put an i at the end,
eg

if message.subj =~ /\[sup-talk\]/i
  message.add_label "sup"
end

Good luck
Hamish
_______________________________________________
sup-talk mailing list
sup-talk@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-talk


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [sup-talk] Hints on debugging hooks
  2010-10-19  9:18 [sup-talk] Hints on debugging hooks Shadowfirebird
  2010-10-19 17:31 ` Michael Stapelberg
  2010-10-19 18:18 ` Hamish D
@ 2010-10-20 21:00 ` Shadowfirebird
  2 siblings, 0 replies; 4+ messages in thread
From: Shadowfirebird @ 2010-10-20 21:00 UTC (permalink / raw)
  To: sup-talk

Thanks for all those suggestions.  

I hadn't even known how to get to sup from irb!  And I don't think debug is documented -- or is it?

Lot of stuff for me to try here.   Expect more dumb questions a bit later...


-- 
There are two types of people in this world, good and bad.  The good
sleep better, but the bad seem to enjoy the waking hours much more.
		-- Woody Allen
_______________________________________________
sup-talk mailing list
sup-talk@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-talk


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-10-20 21:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-19  9:18 [sup-talk] Hints on debugging hooks Shadowfirebird
2010-10-19 17:31 ` Michael Stapelberg
2010-10-19 18:18 ` Hamish D
2010-10-20 21:00 ` Shadowfirebird

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox