My program has a Tk front end and allows users to invoke all sorts of functions via various widgets. If a function has a problem it can change the color of the LogFile widget to indicate trouble, and clicking the LogFile button opens the logfile for inspection.

I think I can live with all the functions dumping their various warnings and such into one file. My question is, if programs (under "my" control) are individually opening the logfile via '>>' for their error logging, what problems might I face? My goal is to interweave my log messages (via warn to a redirected STDERR) with any sort of system log messages.

As an example, the following program seems to "share" the file okay. What might beset me with this approach?

#!/usr/bin/perl -w # show two concurrent processes intermingling their STDERR to the same + file. # Name the program 'test_err.pl' and invoke it from command line with: # test_err.pl hs use strict; my $err_file = 'errfile.txt'; open STDERR, ">> $err_file" or die "cannot open initial $err_file: $!\n"; my $what_to_do = shift; warn "$what_to_do hello world\n"; system( 'test_err.pl', 'abc' ) if $what_to_do eq 'hs'; my $test_string; warn "success\n" if $test_string eq 'xyz'; warn "$what_to_do goodbye world\n"; # Adds the following text to 'errfile.txt': __DATA__ hs hello world abc hello world Use of uninitialized value in string eq at C:\aa\test_err.pl line 19. abc goodbye world Use of uninitialized value in string eq at C:\aa\test_err.pl line 19. hs goodbye world

In reply to multiple programs sharing redirected STDERR by ff

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.