Skip to content

Instantly share code, notes, and snippets.

@stereosupersonic
Created October 14, 2009 10:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stereosupersonic/209967 to your computer and use it in GitHub Desktop.
Save stereosupersonic/209967 to your computer and use it in GitHub Desktop.
Time Logging Proc
def self.in_time_log(name="",logger=nil)
(logger || RAILS_DEFAULT_LOGGER).info("#{name} start")
start_time = Time.now
yield
duration = Time.now-start_time
(logger || RAILS_DEFAULT_LOGGER).info("#{name} duration: #{ ([duration/3600, duration/60 % 60, duration % 60].map{|t| "%02d" % t.to_i.to_s}).join(':')}")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment