Skip Menu |

This queue is for tickets about the Log-Tiny CPAN distribution.

Report information
The Basics
Id: 125386
Status: new
Priority: 0/
Queue: Log-Tiny

People
Owner: Nobody in particular
Requestors: purification [...] ukr.net
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Logging to a file is always buffered
Date: Wed, 23 May 2018 09:21:03 +0300
To: bug-Log-Tiny [...] rt.cpan.org
From: purification [...] ukr.net
This is Log::Tiny 1.0 on perl 5.26.2. Testcase: In terminal #1: % touch myapp.log % tail -f myapp.log In terminal #2: % perl -E 'use Log::Tiny; my $LT = Log::Tiny->new("./myapp.log"); $LT->INFO("first"); sleep 5; $LT->INFO("second"); sleep 5; $LT->INFO("third")' Expected result: logfile can be tail'ed to see messages in real time. Actual result: logfile stays empty until program finishes. Reason of bug: Tiny.pm lines 201-205: { my $autoflush = $|++; $ret = print {$self->{logfh}} $tmp; $| = $autoflush; } $| only affects currently selected output (i.e. usually STDOUT) and will not have any effect on a filehandle opened into a file. To fix this, $logfh->autoflush(1) can be used in sub new after open() call.