I have to admit that I'm too busy right now to review your code, but you asked that I reply here to a couple of points from your other thread.

I had to do something like what you describe for a log module I wrote, (although kind of the opposite as you will see). The objective was to retrofit a bunch of existing poorly looged scripts. My idea was to write a module that would allow a simple added use line to cause all activity on STDERR and STDOUT to get redirected to a log file. My approach was to tie STDOUT and STDERR, as well as add traps to $SIG{__WARN__} and $SIG{__DIE__}. (In hindsight overriding CORE::GLOBAL::die() and CORE::GLOBAL::warn() might have been better, but this catches errors from Perl itself, which can be useful.)

This way virtually all output activity is intercepted, regardless if a module is the one that used the logger or not. In fact it probably is simpler than your approach as things like warnings::warn() actually use Carp which in turn use CORE::warn, which is in turn intercepted by the $SIG{__WARN__} handler, likewise for die().

Generally speaking it works well, problems however occur when programs use sneaky ways to get access to the standard filehandles, and when other code installs $SIG{__FOO__} handlers and doesnt behave nicely. The latter is rare, but difficult to deal with as there isnt really a stated "nice" behaviour. For me its been rare enough that it hasnt been an issue. I still wonder when itll bite me though. :-)

Anyway, I still think that arguably the best thing to do in your situation, is write a logfile reader, or a sanitizer of some sort. This is the only real way to address the fact that it will be almost impossible to intercept all writes to the log files in question wheras it is probably feasable to ensure that the files are not read without a tool. But thats not for me to decide is it? :-)

---
demerphq



In reply to Re: Safe::Logs - Feedback appreciated by demerphq
in thread Safe::Logs - Feedback appreciated by fokat

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



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.