File tree Expand file tree Collapse file tree 2 files changed +5
-2
lines changed
Filter options
Expand file tree Collapse file tree 2 files changed +5
-2
lines changed
Original file line number Diff line number Diff line change @@ -140,6 +140,7 @@ sub close {
140
140
if ($@ || !$written ) {
141
141
my $size = length $self -> {pending };
142
142
$self -> _carp(" Can't send pending data. LOST $size bytes.: $@ " );
143
+ $self -> _call_buffer_overflow_handler();
143
144
}
144
145
else {
145
146
$self -> _carp(" pending data was flushed successfully" );
@@ -341,6 +342,7 @@ You can inject your own custom coderef to handle buffer overflow in the event of
341
342
This will mitigate the loss of data instead of simply throwing data away.
342
343
343
344
Your proc should accept a single argument, which will be the internal buffer of messages from the logger.
345
+ This coderef is also called when logger.close() failed to flush the remaining internal buffer of messages.
344
346
A typical use-case for this would be writing to disk or possibly writing to Redis.
345
347
346
348
=item truncate_buffer_at_overflow
Original file line number Diff line number Diff line change @@ -18,9 +18,10 @@ my $no_such_logger = Fluent::Logger->new(
18
18
for (1..10) {
19
19
$no_such_logger -> post(" test" , { " k" => " v" x (1024 * 1024) });
20
20
}
21
- undef $no_such_logger ;
21
+ is $handler_called , 1, ' called once at buffer_overflow ' ;
22
22
23
- is $handler_called , 1;
23
+ undef $no_such_logger ;
24
+ is $handler_called , 2, ' called once at close' ;
24
25
25
26
done_testing;
26
27
You can’t perform that action at this time.
0 commit comments