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
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.loadIf 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 at 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
> 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
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