Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Why can't I write to a custom log from a Catalyst application on SELinux/CentOS

by choroba (Cardinal)
on Feb 11, 2021 at 15:46 UTC ( [id://11128230]=note: print w/replies, xml ) Need Help??


in reply to Why can't I write to a custom log from a Catalyst application on SELinux/CentOS

Did you
close LOG;
somehwere later, too? If not and the program is still running, the contents might still be waiting in the buffer.
map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Replies are listed 'Best First'.
Re^2: Why can't I write to a custom log from a Catalyst application on SELinux/CentOS
by LanX (Saint) on Feb 11, 2021 at 17:36 UTC
    > close LOG;

    Hm ... I already mentioned $|

    https://perldoc.perl.org/perlvar#$OUTPUT_AUTOFLUSH

    Though the documentation says

    > forces a flush right away and after every write or print on the currently selected output channel.

    so, this means one has to select LOG before using it???°

    IO::Handle mentions a method autoflush

    BUT from my experience are opened handles per default unbuffered???

    Or are they only line-buffered, and the OP forgot the trailing "\n"?

    °) and after some digging I found this in the FAQ

    { my $previous_default = select(STDOUT); # save previous default $|++; # autoflush STDOUT select(STDERR); $|++; # autoflush STDERR, to be +sure select($previous_default); # restore previous default }

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

      > Or are they only line-buffered, and the OP forgot the trailing "\n"?

      Nope, from testing in the debugger, do new handles automatically autoflush

      DB<280> open LOG, ">>", "log.txt" DB<281> ! type log.txt DB<282> print LOG "bla" DB<283> ! type log.txt bla DB<284> DB<284> print LOG "\n" DB<285> ! type log.txt bla DB<286>

      probably is Catalyst bending the defaults?

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery

        Not sure about the debugger, but code shows otherwise:
        #!/usr/bin/perl use strict; use warnings; use feature qw{ say }; open OUT, '>', 'log.txt' or die $!; print OUT "bla\n"; open IN, '<', 'log.txt' or die $!; my $nothing = <IN>; say "Read: $nothing.\n"; close OUT; my $bla = <IN>; say "Read: $bla.\n";
        map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11128230]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (5)
As of 2024-04-19 06:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found