Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ActionLogger
- @@queue = []
- @@limit = (Rails.env == 'development' ? 0 : 100 )
- def self.add(str)
- @@queue.push(str)
- store! if @@queue.size >= @@limit
- end
- def self.store!
- f = File.new("log/actions#{Date.today.to_s}.log", 'a')
- flush().each do |act|
- f.puts(act)
- end
- f.close
- end
- protected
- def self.flush()
- a = @@queue
- @@queue = []
- return a
- end
- end
- at_exit do
- ActionLogger.store!
- end
Add Comment
Please, Sign In to add comment