Created
March 10, 2012 11:15
-
-
Save tarnfeld/2011181 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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