I made a debugging Perl-function to display the text,caller and right caller in the terminal.you can call the function wit text and a level from 0-3.
#!/usr/bin/perl use strict; #example calling first(); sub first{ second(); } sub second{ third(); } sub third{ debug("hint text!");#hint debug("debug text!",1);#debug debug("warning text!",2);#warning debug("error text!",3);#error } #debugging sub sub debug{ my $debug = shift//"";#text my $level = shift//0;#level my ($package, $filename, $line, $subroutine, $hasargs,$wantarray, $evaltext, $is_require, $hints, $bitmask, $hinthash) = caller(0); print "e[32m".("="x16)." HINT ".("="x16)."n" if($level == 0);#green print "e[37m".("="x16)." DEBUG ".("="x16)."n" if($level == 1);#white print "e[33m".("="x16)." WARNING ".("="x16)."n" if($level == 2);#yellow print "e[31m".("="x16)." ERROR ".("="x16)."n" if($level == 3);#red print "File:$filename, Packege:$package, Time:".((time()-$^T)/1000)."sn"; my @callers = (); for(my $i;1;++$i){#get other callers ($package, $filename, $line, $subroutine, $hasargs,$wantarray, $evaltext, $is_require, $hints, $bitmask, $hinthash) = caller($i); last if($subroutine eq ''); $callers[$i] = "-> $line:$subroutine(); "; } print join('',reverse @callers);#reverse and build print "n"; if($debug ne ""){# if text is available print "Text:$debugn"; } print "".("="x16)."=========".("="x16)."ne[37m";#reset color die if($level == 3);# die if there is a error }
This is the result of the 4 debugging levels with 4 different colours:
For Info about Terminal colour see this : Perl Terminal colours.
It’s great that you are getting ideas from this piece of writing as
well as from our argument made at this time.
Hi there, I enjoy reading through your post. I wanted to write a little comment to support you.
Hello there! Do you use Twitter? I’d like to
follow you if that would be okay. I’m definitely enjoying your blog and look forward to new
posts.
yes take a look at https://twitter.com/ScheinastPaul
certainly like your web-site however you need
to test the spelling on quite a few of your posts. A number of them are
rife with spelling issues and I in finding it very troublesome
to tell the truth however I’ll certainly come back again.
Rather than finding Rodriguez, refinancing and her coconspirators presented loan applications within straw
buyers”’s names who supposedly bought the properties.
Havve a look at my blog – ral eatate investment
company name ideas ()
I used to be able to find good info from your articles.
Quality posts is the secret to interest the visitors to pay
a quick visit the web site, that’s what this web site is providing.
This paragraph presents clear idea in favor of
the new users of blogging, that in fact how to do blogging and site-building.
I think the admin of this site is actually working hard for
his web site, since here every data is quality based material.
I couldn’t refrain from commenting. Perfectly written!
Ahaa, its good conversation on the topic of this paragraph here at this
webpage, I have read all that, so now me also commenting here.
Hi there, I found your blog by the use of Google while searching for
a similar subject, your web site came up, it seems great.
I have bookmarked it in my google bookmarks.
Hi there, simply was aware of your blog thru Google, and found that it’s truly
informative. I’m going to be careful for brussels.
I’ll be grateful in the event you proceed this in future.
Many other people will likely be benefited out of your writing.
Cheers!
Hey there! I simply want to give you a huge thumbs up for your excellent info you have got
right here on this post. I am returning to your blog for more soon.
Right now it sounds like WordPress is the preferred blogging platform available right now.
(from what I’ve read) Is that what you’re using on your blog?
I like the valuable info you provide in your articles.
I will bookmark your blog and check again here frequently.
I’m quite sure I’ll learn many new stuff right here! Good
luck for the next!