Mailinglist Archive: yast-commit (2114 mails)

< Previous Next >
[yast-commit] <rest-service> master : initial prototype of log viewer
  • From: Duncan Mac-Vicar P <dmacvicar@xxxxxxx>
  • Date: Mon, 21 Sep 2009 10:36:02 +0200
  • Message-id: <E1MpefH-000617-4M@xxxxxxxxxxxxxxxx>
ref: refs/heads/master
commit f16d1be9c10a42be21406f5efbbadd7f0bdd5a60
Author: Duncan Mac-Vicar P <dmacvicar@xxxxxxx>
Date: Thu Sep 3 18:38:54 2009 +0200

initial prototype of log viewer
---
webservice/app/controllers/logs_controller.rb | 39 +++++++++++++++++++++++++
webservice/config/routes.rb | 2 +
2 files changed, 41 insertions(+), 0 deletions(-)

diff --git a/webservice/app/controllers/logs_controller.rb
b/webservice/app/controllers/logs_controller.rb
new file mode 100644
index 0000000..7f0122b
--- /dev/null
+++ b/webservice/app/controllers/logs_controller.rb
@@ -0,0 +1,39 @@
+require 'scr'
+
+class LogsController < ApplicationController
+
+ def index
+ end
+
+ def show
+
+ log_filename = case params[:id]
+ when "messages" then '/var/log/messages'
+ when "apache_access" then '/var/log/apache2/access_log'
+ when "apache_error" then '/var/log/apache2/error_log'
+ else nil
+ end
+
+ # not found
+ if log_filename.nil?
+ render :nothing, :status => 404 and return
+ end
+
+ # how many lines to show
+ lines = case params[:lines]
+ when nil then 50
+ else params[:lines].to_i
+ end
+
+ output = Scr.instance.execute(['tail', '-n', "#{lines}", log_filename])
+
+ respond_to do |format|
+ format.xml { render :xml => settings.to_xml }
+ format.json { render :json => VendorSetting }
+ end
+
+ #render :text => output[:stdout]
+ render :xml => xm.target!
+ end
+
+end
diff --git a/webservice/config/routes.rb b/webservice/config/routes.rb
index be16af4..5dae060 100644
--- a/webservice/config/routes.rb
+++ b/webservice/config/routes.rb
@@ -9,4 +9,6 @@ ActionController::Routing::Routes.draw do |map|
map.login "/login.:format", :controller => 'sessions', :action => 'create'
map.logout "/logout.:format", :controller => 'sessions', :action => 'destroy'

+ map.resources :logs
+
end
--
To unsubscribe, e-mail: yast-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages