Created
July 27, 2011 10:30
-
-
Save kyanny/1109108 to your computer and use it in GitHub Desktop.
Log::Minimal - convenient logger wrapper for your rails app inspired by Log::Minimal CPAN module
This file contains 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
module Log | |
module Minimal | |
[:fatal, :error, :warn, :info, :debug].each do |method| | |
define_method "#{method}f" do |message| | |
time = Time.now.iso8601 | |
level = method.to_s.upcase | |
caller = "%s#%s:%s" % [self.class, action_name, caller(1)[0].scan(/:(\d+):/)] | |
logger.send(method, "%s [%s] %s %s" % [time, level, caller, message]) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to use it:
in application.rb or application_controller.rb
in your foo_controller.rb
then you can get informative log message :)