mirror of
https://github.com/meineerde/rackstash.git
synced 2025-10-17 14:01:01 +00:00
Flush silent Buffers by default
With the change to allow ading fields to the Buffer with a Logger interface in the previous commit, we should also flush those Buffers with fields set that way by default.
This commit is contained in:
parent
013d0f7d92
commit
021dbc256b
@ -79,7 +79,7 @@ module Rackstash
|
||||
# were just added fields or tags without any logged messages. If this is
|
||||
# `false` and there were no messages logged with {#add_message}, the
|
||||
# buffer will not be flushed to the sink but will be silently dropped.
|
||||
def initialize(sink, buffering: true, allow_silent: false)
|
||||
def initialize(sink, buffering: true, allow_silent: true)
|
||||
@sink = sink
|
||||
@buffering = !!buffering
|
||||
@allow_silent = !!allow_silent
|
||||
|
||||
@ -14,8 +14,8 @@ describe Rackstash::Buffer do
|
||||
let(:buffer) { described_class.new(sink, **buffer_options) }
|
||||
|
||||
describe '#allow_silent?' do
|
||||
it 'defaults to false' do
|
||||
expect(buffer.allow_silent?).to be false
|
||||
it 'defaults to true' do
|
||||
expect(buffer.allow_silent?).to be true
|
||||
end
|
||||
end
|
||||
|
||||
@ -101,6 +101,28 @@ describe Rackstash::Buffer do
|
||||
buffer.add_fields(key: 'value')
|
||||
end
|
||||
|
||||
context 'when allow_silent?' do
|
||||
before do
|
||||
buffer_options[:allow_silent] = true
|
||||
end
|
||||
|
||||
it 'sets pending? to true' do
|
||||
buffer.add_fields(key: 'value')
|
||||
expect(buffer.pending?).to be true
|
||||
end
|
||||
end
|
||||
|
||||
context 'when not allow_silent?' do
|
||||
before do
|
||||
buffer_options[:allow_silent] = false
|
||||
end
|
||||
|
||||
it 'does not set pending? to true' do
|
||||
buffer.add_fields(key: 'value')
|
||||
expect(buffer.pending?).to be false
|
||||
end
|
||||
end
|
||||
|
||||
context 'when buffering?' do
|
||||
before do
|
||||
buffer_options[:buffering] = true
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user