You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

system_log_controller.rb 1.8 kB

11 years ago
​
​
​
11 years ago
​
​
​
​
11 years ago
​
​
​
​
​
11 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
11 years ago
11 years ago
​
​
​
​
​
​
​
​
​
​
11 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. # Time 2015-01-26 17:12:23
  2. # Author lizanle
  3. # Description 显示和清理系统日志
  4. class SystemLogController < ApplicationController
  5. before_filter :require_admin
  6. # 默认每页显示20条记录
  7. PER_PAGE = 20
  8. layout "base"
  9. include SystemLogHelper
  10. # Time 2015-01-26 17:12:46
  11. # Author lizanle
  12. # Description 查看所有日志
  13. def index
  14. @logs = SystemLog.logo_data(params[:page]||1, params[:per]||PER_PAGE, params[:search], params[:day])
  15. end
  16. # Time 2015-01-26 14:42:38
  17. # Author lizanle
  18. # Description 清除日志
  19. def clear
  20. SystemLog.clear params[:day]
  21. redirect_to :action => :index
  22. end
  23. # Time 2015-01-26 17:24:25
  24. # Author lizanle
  25. # Description 访问分析
  26. def access_analysis
  27. #解析日志,然后逆序
  28. @log_result = SystemLog.analysis(params[:day]).reverse[1...-1]
  29. @access_module = Hash.new
  30. #日誌可能為空
  31. if @log_result && !@log_result.empty?
  32. #将数组中的模块访问统计出来放到hash中 每条记录的第四个值是Controller#action的形式
  33. @log_result.collect! { |r| @access_module[r[3]].nil? ?
  34. @access_module[r[3]] = 1 : @access_module[r[3]] +=1 }
  35. # 去掉key可能为空记录 排序,然后取逆序
  36. @access_module = @access_module.delete_if { |k, v| k.nil? }.sort_by { |key, val| val }.reverse
  37. else
  38. @access_module
  39. end
  40. end
  41. # Time 2015-01-26 17:24:36
  42. # Author lizanle
  43. # Description 耗时分析
  44. def time_analysis
  45. #解析日志
  46. @log_result = SystemLog.analysis(params[:day]).reverse[1...-1]
  47. if @log_result && !@log_result.empty?
  48. #分页
  49. @log_result = Kaminari.paginate_array(@log_result).page(params[:page]||1).per(params[:per]||PER_PAGE)
  50. else
  51. @log_result = []
  52. end
  53. end
  54. end

软件技术创新是当今国家整体创新能力的重要基础和发展引擎。近年来,大众参与的软件创新与创业活动已经成为网络时代软件开发和应用的新形态,正在快速改变着全球软件创新模式和软件产业格局。 ...