Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add logging information to perl legacy code

Tags:

perl

I have a medium to large size system built in perl, that has been developed during the last 15 years and is built of many scripts and pm files, and in order to improve the system i need more data, the easiest way as i see it to get this data is to have every function in the code to print out the start and end time to some log so it will be possible the understand what is taking the most time. however this is an old system and some parts are less maintainable than others and on top of it i need it to be running which means in order to get real data i need it to print this out from production. what i want to do is to override in some way the function declration to wrap each function start in a line like NAME start STARTTIME PARAMS and when it leaves the function NAME ended STARTTIME PARAMS

does anybody can point me to the right direction? Thanks

like image 335
Srgrn Avatar asked Nov 23 '25 11:11

Srgrn


1 Answers

Take a look at Devel::NYTProf. It can profile the amount of time that all of your subs are taking (and do a lot more). It doesn't involve a lot of messy code modification; instead you just run your script with it:

perl -d:NYTProf your_script.pl