Skip to content

Instantly share code, notes, and snippets.

@tarnfeld
Created March 10, 2012 11:15
Show Gist options
  • Save tarnfeld/2011181 to your computer and use it in GitHub Desktop.
Save tarnfeld/2011181 to your computer and use it in GitHub Desktop.
begin
require "rainbow"
rescue LoadError => e
# Lets not worry about this
end
module Snowey
module Logger
def message message
puts "#{prefix} - #{message}"
end
def error error
puts color("#{prefix} - #{error}", "#FF0000")
end
module_function :message
module_function :error
private
def prefix
pid = color("[#{Process.pid}]", "#429dbc")
time = Time.now.strftime("%d %b %H:%M:%S")
"#{pid} #{time}"
end
def color string, color
if string.respond_to?(:color)
return string.color(color)
end
string
end
module_function :prefix
module_function :color
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment