mirror of
https://github.com/meineerde/rackstash.git
synced 2025-10-17 14:01:01 +00:00
Allow to define a suitable default encoder per adapter
The global default (unless overwritten by an adapter class) is to use the JSON encoder since it's the most versatile and flexible option for a logger today.
This commit is contained in:
parent
bf178ef36d
commit
b3f9a63253
@ -41,6 +41,15 @@ module Rackstash
|
||||
def initialize(*)
|
||||
end
|
||||
|
||||
# Return a new Encoder instance which can be used with the concrete adapter
|
||||
# If no explicit encoder is defined in a {Flow}, this encoder will be used
|
||||
# there
|
||||
#
|
||||
# @return [#call] an encoder
|
||||
def default_encoder
|
||||
Rackstash::Encoders::JSON.new
|
||||
end
|
||||
|
||||
# Close the underlying log device if supported by it.
|
||||
#
|
||||
# This method needs to be overwritten in child classes. By default, this
|
||||
|
||||
@ -18,6 +18,12 @@ describe Rackstash::Adapters::Adapter do
|
||||
end
|
||||
end
|
||||
|
||||
describe '.default_encoder' do
|
||||
it 'returns an encoder' do
|
||||
expect(adapter.default_encoder).to respond_to(:encode)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#close' do
|
||||
it 'does nothing' do
|
||||
expect(adapter.close).to be nil
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user