|Welcome to the Monastery|
How to capture (intercept) output (warnings) of a moduleby davidfilmer (Sexton)
|on Sep 05, 2020 at 07:04 UTC||Need Help??|
davidfilmer has asked for the wisdom of the Perl Monks concerning the following question:
Greetings, Masters. I have an oddball module (Graphics::TIFF, but that's not really relevant; my question is not about the module itself). It is emitting warning messages to the console, such as:
TIFFReadDirectory: Warning, Unknown field with tag 37724 (0x935c) encountered.
The method that I am calling (my $count = $tiff->NumberOfDirectories();) succeeds, and the method returns the correct value for $count (NumberOfDirectories), while also emitting that warning message to the console. It does not return the warning message (it returns the number of directories, as it should).
The module is not setting $! or anything (return code is zero, since it counted the directories) - these are just warning messages. But the module doesn't provide any method for me to access these warnings, other than just dumping my program output to a file (which I would then have to subsequently parse through - groan).
I'm running my job in batch - I want to capture these warnings to a log database. So (I think) I need to somehow tell my program to watch STDOUT/STDERR from this module and capture any messages.
How do I do that, Masters?