DEV Community

Discussion on: Logging Rails requests with structure and colors

Collapse
 
rhymes profile image
rhymes

You should put everything in a lograge initializer.

# config/initializers/lograge.rb
require 'colorized_string'

class ColorKeyValue < Lograge::Formatters::KeyValue
  # ...
end

Rails.application.configure do
  config.lograge.enabled = true
  config.lograge.formatter = ColorKeyValue.new
end
Collapse
 
alvinwch profile image
AlvinWCH

thank you ! but I think got the error at this line : color = FIELDS_COLORS[key] || :default

Could not log "process_action.action_controller" event. NoMethodError: undefined method `default' for "user_type=NONE":ColorizedString ["/Users/alvin/Documents/flw/config/initializers/lograge.rb:24

Thread Thread
 
rhymes profile image
rhymes

Can you share the whole file? You can use stuff gist.github.com/ or pastebin.com/