Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

lbe, I am just looking at these modules right now. It is great that one can separate log output depending on categories but it seems to me that they don't actually catch print statements and redirect them but rather handle their own logger messages.

Ideally what I want is, given a perl program possibly using many modules, to run it and have every single print statement 1) redirected to file and 2) prepended by (filename,modulename,subname,linenumber). If I am given that program, it means I can clone it and replace all print statements with log statements but 1) what about print statements inside 3rd-party modules and 2) extra complication if bleached.

What I am doing right now and works is 1) redirect STDOUT to file 2) tie STDOUT to a class so when any print is called on that filehandle, I intercept the call and prepend the caller's fingerprint all the way to the top of the frame (<main>).

The module I mentioned works well but I had to extend it in order to handle STDERR and also for redirecting to a file (implementing OPEN/CLOSE).

In case you have a suggestion: my current problem is what data structure to use for storing all these print statements' output so that, for example, I make queries like: what is the STDOUT for lines X-Y, filename Z or do not show me output for lines so and so or sub so and so or package so and so. The data is all there but structuring it in order to make these queries is my next stop. I am currently playing with tree. I will sure post a separate request about these problems.

thanks, bliako


In reply to Re^4: Override printing to STDOUT/ERR by bliako
in thread Override printing to STDOUT/ERR by bliako

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2024-04-26 01:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found