1
0
mirror of https://github.com/meineerde/rackstash.git synced 2025-10-17 14:01:01 +00:00

Add Raw encoder which just passes the log event

This commit is contained in:
Holger Just 2017-06-07 13:00:24 +02:00
parent 16d76a7217
commit 0aa39483dd
3 changed files with 39 additions and 0 deletions

View File

@ -4,3 +4,4 @@
# of the MIT license. See the LICENSE.txt file for details.
require 'rackstash/encoders/json'
require 'rackstash/encoders/raw'

View 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

View 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