Skip to content

Instantly share code, notes, and snippets.

@odigity
Created October 8, 2015 15:44
Show Gist options
  • Select an option

  • Save odigity/faba40e04d6210007cb7 to your computer and use it in GitHub Desktop.

Select an option

Save odigity/faba40e04d6210007cb7 to your computer and use it in GitHub Desktop.
Colorizing Sequel logger
require 'colorize'
class CLogger < Logger
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
message = message.colorize(color)
super(message)
end
end
Sequel.mysql2(dbname,
...credentials...
loggers: [CLogger.new($stdout)],
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment