I googled "ruby sql colorize logger", but found nothing obvious.  I did 
find the 'colorize' gem, though, with a bit of digging, came up with this:

https://gist.github.com/odigity/faba40e04d6210007cb7

require 'colorize'

class CLogger < Logger

  def error(message)
    super(message.colorize(:light_red))
  end

  def info(message)
    color = case message
    when Regexp.union(%w[CREATE ALTER DROP])
      :light_blue
    when Regexp.union(%w[INSERT UPDATE DELETE])
      :light_yellow
    else
      :yellow
    end
    super(message.colorize(color))
  end

  def warn(message)
    super(message.colorize(:red))
  end

end

Sequel.mysql2(dbname,
  ...credentials...
  loggers:  [CLogger.new($stdout)],
)


Which seems to work well enough.

-ofer

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to