Skip to content

Commit

Permalink
Merge pull request #736 from natematykiewicz/logger_performance
Browse files Browse the repository at this point in the history
Improve performance of `color_name` function in log subscriber
  • Loading branch information
jnunemaker authored Jun 7, 2023
2 parents 4e31057 + b6625ed commit 8a6b5c9
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions lib/flipper/instrumentation/log_subscriber.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,17 @@ def logger

private

# 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.
COLOR_OPTIONS = if Rails.gem_version > Gem::Version.new('7.0.99')
{ bold: true }.freeze
else
true
end
private_constant :COLOR_OPTIONS

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
color(name, CYAN, COLOR_OPTIONS)
end
end
end
Expand Down

0 comments on commit 8a6b5c9

Please sign in to comment.