Skip to content

Commit

Permalink
Merge pull request #726 from piperswe/rails-7.1-hash-bold
Browse files Browse the repository at this point in the history
Use new method of making logs bold
  • Loading branch information
jnunemaker authored May 23, 2023
2 parents 48cf8e0 + 9bf1c79 commit e9d98a7
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions lib/flipper/instrumentation/log_subscriber.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def feature_operation(event)
details += " gate_name=#{gate_name}" unless gate_name.nil?

name = '%s (%.1fms)' % [description, event.duration]
debug " #{color(name, CYAN, true)} [ #{details} ]"
debug " #{color_name(name)} [ #{details} ]"
end

# Logs an adapter operation. If operation is for a feature, then that
Expand Down Expand Up @@ -64,12 +64,24 @@ def adapter_operation(event)
details = "result=#{result.inspect}"

name = '%s (%.1fms)' % [description, event.duration]
debug " #{color(name, CYAN, true)} [ #{details} ]"
debug " #{color_name(name)} [ #{details} ]"
end

def logger
self.class.logger
end

private

def color_name(name)
# Rails 7.1 changed the signature of this function.
# Checking if > 7.0.99 rather than >= 7.1 so that 7.1 pre-release versions are included.
if Rails.gem_version > Gem::Version.new('7.0.99')
color(name, CYAN, bold: true)
else
color(name, CYAN, true)
end
end
end
end

Expand Down

0 comments on commit e9d98a7

Please sign in to comment.