Skip to content

Instantly share code, notes, and snippets.

@igor-alexandrov
Created March 2, 2010 19:42
Show Gist options
  • Save igor-alexandrov/319835 to your computer and use it in GitHub Desktop.
Save igor-alexandrov/319835 to your computer and use it in GitHub Desktop.
require 'rainbow'
def log(level, message)
Rails.logger.send level, message.foreground(color_for_level(level))
if RAILS_ENV == 'development'
puts level.to_s.upcase " " message.foreground(color_for_level(level))
end
end
def color_for_level(level)
case level
when :error: :red
when :alert: :blue
when :info: :green
default: :black
end
end
def notify(level, message)
flash[:notifications] ||= {}
flash[:notifications][level] = message
logger.error("ERROR: #{message}") if type == :error
end
<% unless flash[:notifications].nil? %>
<%= stylesheet_link_tag "notifications" %>
<% flash[:notifications].each do |key, value| %>
<div class="g-notification g-notification-<%= key %>">
<%= value %>
</div>
<% end -%>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment