A solution to add debugger functionality most koha *.pl scripts, thoughts please?
Hi Koha developers, I have been talking with John and Paul at BibLibre for some months now about a correct way to add Data::Dumper, Smart::Comments, insert::your::favorite::debugger stuff to the Koha perl files *once and for all* After a few false starts and some googling - this is the method I have used and tested... use C4::Debug; use if $debug, 'Data::Dumper' ; use if $debug, 'Smart::Comments' ; # use if $debug, 'YAML::Dumper; # etc.... It's short, sweet and works a treat ;) I currently waste much time every day adding/removing 'use Data::Dumper/use Smart::Comments' from my files when debugging and then committing patches to koha.org Can we agree to add this code (or something similar) to most *.pm and *.pl files? Is there a better way than this? Is this a bad way? Any improvements or corrections i don't realize? What do other developers do to get around this laborious issue? FYI: this small fix (should it be accepted), will resolve one of my biggest pet-annoyances of the Koha project! Cheers, Mason.
On 2009/02/10, at 6:01 PM, Mason James wrote:
Hi Koha developers,
I have been talking with John and Paul at BibLibre for some months now about a correct way to add Data::Dumper, Smart::Comments, insert::your::favorite::debugger stuff to the Koha perl files *once and for all*
After a few false starts and some googling - this is the method I have used and tested...
use C4::Debug; use if $debug, 'Data::Dumper' ; use if $debug, 'Smart::Comments' ; # use if $debug, 'YAML::Dumper; # etc....
Is there a better way than this?
A question from me too.. Is there a clever way to add this code to *just* Debug.pm which would enable D::D and S::C functionality to all perl files that 'use C4::Debug'? That would be the cleanest way, i think - but i don't know how to do this, or if it's possible in perl :/ anyone?
Give C4::Debug an import() function like this: sub import { if ($debug) { require Smart::Comments; Smart::Comments->import; require Data::Dumper; Data::Dumper->import; } C4::Debug->export_to_level(1, @_); } That should do the trick. On Mon, Feb 9, 2009 at 9:11 PM, Mason James <mason.loves.sushi@gmail.com>wrote:
On 2009/02/10, at 6:01 PM, Mason James wrote:
Hi Koha developers,
I have been talking with John and Paul at BibLibre for some months now about a correct way to add Data::Dumper, Smart::Comments, insert::your::favorite::debugger stuff to the Koha perl files *once and for all*
After a few false starts and some googling - this is the method I have used and tested...
use C4::Debug; use if $debug, 'Data::Dumper' ; use if $debug, 'Smart::Comments' ; # use if $debug, 'YAML::Dumper; # etc....
Is there a better way than this?
A question from me too..
Is there a clever way to add this code to *just* Debug.pm which would enable D::D and S::C functionality to all perl files that 'use C4::Debug'?
That would be the cleanest way, i think - but i don't know how to do this, or if it's possible in perl :/
anyone?
_______________________________________________ Koha-devel mailing list Koha-devel@lists.koha.org http://lists.koha.org/mailman/listinfo/koha-devel
On 2009/02/10, at 7:30 PM, John Beppu wrote:
Give C4::Debug an import() function like this:
sub import { if ($debug) { require Smart::Comments; Smart::Comments->import; require Data::Dumper; Data::Dumper->import; } C4::Debug->export_to_level(1, @_); }
hot damn - that works perfectly ;) thanks John!
Also, if you want to be able to just type "Dumper" (instead of Data::Dumper::Dumper), add "Dumper" to the list of symbols that C4::Debug exports. On Mon, Feb 9, 2009 at 10:30 PM, John Beppu <john.beppu@liblime.com> wrote:
Give C4::Debug an import() function like this:
sub import { if ($debug) { require Smart::Comments; Smart::Comments->import; require Data::Dumper; Data::Dumper->import; } C4::Debug->export_to_level(1, @_); }
That should do the trick.
On Mon, Feb 9, 2009 at 9:11 PM, Mason James <mason.loves.sushi@gmail.com>wrote:
On 2009/02/10, at 6:01 PM, Mason James wrote:
Hi Koha developers,
I have been talking with John and Paul at BibLibre for some months now about a correct way to add Data::Dumper, Smart::Comments, insert::your::favorite::debugger stuff to the Koha perl files *once and for all*
After a few false starts and some googling - this is the method I have used and tested...
use C4::Debug; use if $debug, 'Data::Dumper' ; use if $debug, 'Smart::Comments' ; # use if $debug, 'YAML::Dumper; # etc....
Is there a better way than this?
A question from me too..
Is there a clever way to add this code to *just* Debug.pm which would enable D::D and S::C functionality to all perl files that 'use C4::Debug'?
That would be the cleanest way, i think - but i don't know how to do this, or if it's possible in perl :/
anyone?
_______________________________________________ Koha-devel mailing list Koha-devel@lists.koha.org http://lists.koha.org/mailman/listinfo/koha-devel
On 2009/02/10, at 8:15 PM, John Beppu wrote:
Also, if you want to be able to just type "Dumper" (instead of Data::Dumper::Dumper), add "Dumper" to the list of symbols that C4::Debug exports.
On Mon, Feb 9, 2009 at 10:30 PM, John Beppu <john.beppu@liblime.com> wrote: Give C4::Debug an import() function like this:
sub import { if ($debug) { require Smart::Comments; Smart::Comments->import; require Data::Dumper; Data::Dumper->import; } C4::Debug->export_to_level(1, @_); }
That should do the trick.
Woo, this is all new stuff for me. I'll play about and test this code of yours during my work week, and read up on the OO->import example you gave. I aim to send in a patch based on your code in the next few days. Thanks again John!
On Tue, Feb 10, 2009 at 9:38 AM, Mason James <mason.loves.sushi@gmail.com>wrote:
Woo, this is all new stuff for me.
I'll play about and test this code of yours during my work week, and read up on the OO->import example you gave.
I aim to send in a patch based on your code in the next few days.
Thanks again John!
If you ever look at the source for Moose or Mouse, it's the same technique they use to automagically turn on strict and warnings for you. --beppu
participants (2)
-
John Beppu -
Mason James