diff --git a/lib/rackstash/encoders/helpers/message.rb b/lib/rackstash/encoders/helpers/message.rb index 0279a96..38221a5 100644 --- a/lib/rackstash/encoders/helpers/message.rb +++ b/lib/rackstash/encoders/helpers/message.rb @@ -10,6 +10,8 @@ module Rackstash # Some useful helper methods for {Encoders} which help in normalizing and # handling the message list in the event Hash. module Message + private + # Normalize the `"message"` field of the given log event Hash. # # While the filters still had access to the array of {Message} objects @@ -24,7 +26,7 @@ module Rackstash # @param event [Hash] a log event Hash # @return [Hash] the given event with the `"message"` key set as a # single string. - def normalize_message(event) + def normalize_message(event) #:doc: event[FIELD_MESSAGE] = case event[FIELD_MESSAGE] when Array diff --git a/lib/rackstash/encoders/helpers/timestamp.rb b/lib/rackstash/encoders/helpers/timestamp.rb index 4c1da6f..cb04905 100644 --- a/lib/rackstash/encoders/helpers/timestamp.rb +++ b/lib/rackstash/encoders/helpers/timestamp.rb @@ -14,6 +14,8 @@ module Rackstash # handling timestamps in the event Hash, especially the {FIELD_TIMESTAMP} # field. module Timestamp + private + # Normalize the `"@timestamp"` field of the given log event Hash. # Before any filters, only the `"@timestamp"` fueld contains a `Time` # object denoting the timestamp of the log event. To represent this @@ -25,7 +27,7 @@ module Rackstash # hash. By default, we use the `"@timestamp"` field. # @return [Hash] the given event with the `field` key set as an ISO 8601 # formatted time string. - def normalize_timestamp(event, field: FIELD_TIMESTAMP) + def normalize_timestamp(event, field: FIELD_TIMESTAMP) #:doc: time = event[field] if time.is_a?(Time) || time.is_a?(DateTime) diff --git a/spec/rackstash/encoders/helpers/message_spec.rb b/spec/rackstash/encoders/helpers/message_spec.rb index e525b88..b173402 100644 --- a/spec/rackstash/encoders/helpers/message_spec.rb +++ b/spec/rackstash/encoders/helpers/message_spec.rb @@ -9,7 +9,15 @@ require 'spec_helper' require 'rackstash/encoders/helpers/message' describe Rackstash::Encoders::Helpers::Message do - let(:helper) { Object.new.extend(described_class) } + let(:helper) { + helper = Object.new.extend(described_class) + described_class.private_instance_methods(false).each do |method| + helper.define_singleton_method(method) do |*args| + super(*args) + end + end + helper + } let(:event) { {} } describe '#normalize_message' do diff --git a/spec/rackstash/encoders/helpers/timestamp_spec.rb b/spec/rackstash/encoders/helpers/timestamp_spec.rb index c2a872f..c2310b9 100644 --- a/spec/rackstash/encoders/helpers/timestamp_spec.rb +++ b/spec/rackstash/encoders/helpers/timestamp_spec.rb @@ -9,7 +9,15 @@ require 'spec_helper' require 'rackstash/encoders/helpers/timestamp' describe Rackstash::Encoders::Helpers::Timestamp do - let(:helper) { Object.new.extend(described_class) } + let(:helper) { + helper = Object.new.extend(described_class) + described_class.private_instance_methods(false).each do |method| + helper.define_singleton_method(method) do |*args| + super(*args) + end + end + helper + } let(:event) { {} } describe '#normalize_timestamp' do