Module: Logbang::Helper
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/logbang/helper.rb
Overview
Adds the log!
functionality to the Rails ActionController::Base method, and sets up an after_filter to dump the timing statistics at the end of each request.
Instance Method Summary collapse
-
#log!(message = nil) ⇒ Object
Create a log entry with timing data and a unique ID.
Instance Method Details
#log!(message = nil) ⇒ Object
Create a log entry with timing data and a unique ID.
This will show as a yellow log entry like :
= Marked: container-start - 6d5c4c5
If message
is left blank, the caller filename will be used.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/logbang/helper.rb', line 21 def log!(=nil) call_list = caller.find_all { |x| x =~ /#{Rails.root}/ } mycaller = call_list[0].to_s.gsub(/^([^:]+):.*/, '\1') = mycaller.gsub(/#{Rails.root}/,'') if .nil? call_list.reject! { |x| x =~ Regexp.new("^#{mycaller}") } parent = call_list[0].to_s.gsub(/^([^:]+):.*/, '\1') if call_list[0] @log_markers ||= [] time = Time.now.to_f id = Digest::MD5.hexdigest("#{}#{time}") @log_markers << { :time => time, :caller => mycaller, :parent => parent, :marker => , :id => id } Logbang::Railtie.log "Marked: #{} - #{id[0..6]}" end |