mirror of
https://github.com/meineerde/rackstash.git
synced 2025-12-19 15:01:12 +00:00
Add Raw encoder which just passes the log event
This commit is contained in:
parent
16d76a7217
commit
0aa39483dd
@ -4,3 +4,4 @@
|
||||
# of the MIT license. See the LICENSE.txt file for details.
|
||||
|
||||
require 'rackstash/encoders/json'
|
||||
require 'rackstash/encoders/raw'
|
||||
|
||||
19
lib/rackstash/encoders/raw.rb
Normal file
19
lib/rackstash/encoders/raw.rb
Normal file
@ -0,0 +1,19 @@
|
||||
# Copyright 2017 Holger Just
|
||||
#
|
||||
# This software may be modified and distributed under the terms
|
||||
# of the MIT license. See the LICENSE.txt file for details.
|
||||
|
||||
module Rackstash
|
||||
module Encoders
|
||||
# The Raw encoder formats the log event as a raw `Hash` containing all data
|
||||
# exposed by the buffer. This can be used by special log targets which are
|
||||
# designed to handle hashes as opposed to formatted strings.
|
||||
class Raw
|
||||
# @param event [Hash] a log event as produced by the {Flow}
|
||||
# @return [Hash] the passed `event`
|
||||
def encode(event)
|
||||
event
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
19
spec/rackstash/encoders/raw_spec.rb
Normal file
19
spec/rackstash/encoders/raw_spec.rb
Normal file
@ -0,0 +1,19 @@
|
||||
# Copyright 2017 Holger Just
|
||||
#
|
||||
# This software may be modified and distributed under the terms
|
||||
# of the MIT license. See the LICENSE.txt file for details.
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
require 'rackstash/encoders/raw'
|
||||
|
||||
describe Rackstash::Encoders::Raw do
|
||||
let(:encoder) { Rackstash::Encoders::Raw.new }
|
||||
|
||||
describe '#encode' do
|
||||
it 'passes the raw event through' do
|
||||
event = Object.new
|
||||
expect(encoder.encode(event)).to equal event
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
x
Reference in New Issue
Block a user