Skip to content

Commit 34c6710

Browse files
committed
Accept string-like tags responding to to_str
additionally, disallow `Array` arguments
1 parent 9267469 commit 34c6710

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

lib/rage/configuration.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,8 @@ class LogTags < LogContext
300300
private
301301

302302
def validate_input!(obj)
303-
if !obj.is_a?(Array) && !obj.is_a?(String) && !obj.respond_to?(:call)
304-
raise ArgumentError, "custom log tags has to be an Array, String, or Proc"
303+
if !obj.respond_to?(:to_str) && !obj.respond_to?(:call)
304+
raise ArgumentError, "custom log tags has to be a String or a Proc"
305305
end
306306
end
307307
end
@@ -595,7 +595,7 @@ def __finalize
595595
end
596596

597597
if @log_tags
598-
Rage.__log_processor.add_custom_tags(@log_tags.objects.flatten)
598+
Rage.__log_processor.add_custom_tags(@log_tags.objects)
599599
end
600600
end
601601
end

lib/rage/log_processor.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ def build_custom_tags_proc
6565
calls = @custom_tags.map.with_index do |tag_object, i|
6666
if tag_object.is_a?(String)
6767
"@custom_tags[#{i}]"
68+
elsif tag_object.respond_to?(:to_str)
69+
"@custom_tags[#{i}].to_str"
6870
else
6971
"@custom_tags[#{i}].call"
7072
end

0 commit comments

Comments
 (0)