Hi, I need to solve the following:
there are a bunch of perl scripts calling a subroutine
WriteToLog all over the place. IT basically prints out the status of the program flow with time stamp and some other info
into a log file. But I only want those info for certain actions not always and I have identified where those 2 points
are. The WirteToLog is just too noisy. I am thinking of intercepting the WriteToLog call and with a flag, If the flag
is on it prints to log file, it not skips. I do not have access to WriteToLog source code. only the interface.
How to do this? the script layout:
file a.pl
sub func1{
WriteTOLog($Arga,$Argb,$Argc,$Argd); }
... do a bunch of things
<code>
file b.pl
<code>
sub func2{
WriteTOLog($Arga,$Argb,$Argc,$Argd); }
... do a bunch of things
<code>
file c.pl
<code>
sub func3{
WriteTOLog($Arga,$Argb,$Argc,$Argd); }
... do a bunch of things
<code>
file log.pl
<code>
sub WriteToLog($,$,$,$){
local ($var) = @_;
# do its fike IO stuff
}
so can I change WriteTOLog to:
sub MyWriteToLog($,$,$,$){
if ($FLAG eq 1) {
local ($var) = @_;
# do its fike IO stuff
WriteTOLog($a,$b,$c,$d);
} else {
#do nothing or other things;
}
}
how to make those proginal files call MyWriteToLog when they see WriteTOLog? D I really have to change all these files?
2006-02-10 Retitled by broquaint, as per Monastery guidelines
Original title: 'intercept soub routine calls'
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.