Class: ErpApp::Desktop::Tail::BaseController
- Inherits:
-
BaseController
- Object
- ActionController::Base
- ApplicationController
- BaseController
- ErpApp::Desktop::Tail::BaseController
- Defined in:
- app/controllers/erp_app/desktop/tail/base_controller.rb
Instance Method Summary collapse
Methods inherited from BaseController
Instance Method Details
#get_tail ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/controllers/erp_app/desktop/tail/base_controller.rb', line 6 def get_tail contents = [] cursor = params[:cursor].to_i log_file = File.join(Rails.root, 'log', "#{Rails.env}.log") File.open(log_file) do |f| if cursor == 0 f.seek(-1, IO::SEEK_END) else f.seek cursor end if !f.eof? contents = f.readlines cursor = f.tell end end render :json => {:success => true, :tail => contents.join('<br/>'), :cursor => cursor} end |