Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow passing integers as tags to TaggedLogging::Formatter #152

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

maciek-rr
Copy link

Logstash and Elasticsearch accept integer values for keyword type fields, such as tags.

LogStashLogger filters tags, not to pass nils or empty strings as tags to Logstash.
However, the empty string check does fail on everything that is not a string, and it does so in not a
very friendly manner:

irb(main):005:0> stdout_logger.tagged('test', 10) {}
Traceback (most recent call last):
        5: from /Users/irvingwashington/.rubies/ruby-2.5.3/bin/irb:11:in `<main>'
        4: from (irb):5
        3: from /Users/irvingwashington/.gem/ruby/2.5.3/gems/logstash-logger-0.25.1/lib/logstash-logger/tagged_logging.rb:5:in `tagged'
        2: from /Users/irvingwashington/.gem/ruby/2.5.3/gems/logstash-logger-0.25.1/lib/logstash-logger/tagged_logging.rb:18:in `tagged'
        1: from /Users/irvingwashington/.gem/ruby/2.5.3/gems/logstash-logger-0.25.1/lib/logstash-logger/tagged_logging.rb:18:in `ensure in tagged'
NoMethodError (undefined method `size' for nil:NilClass)

This PR makes that check happen only on objects that respond to #empty?.

Logstash and Elasticsearch accept integer values for keyword type
fields, such as tags. LogStashLogger filters tags, not to pass nils
or empty strings as tags to logstash. However, the empty string check
does fail on everything that is not a string, and it does so in not a
very friendly manner.
This PR makes that check happen only on objects that respond to #empty?.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant