输出日志代码
This commit is contained in:
parent
7c97c0391b
commit
5824f70fe3
|
@ -0,0 +1,27 @@
|
|||
module LoggerHelper
|
||||
|
||||
#输出日志
|
||||
def OutLogger
|
||||
#日志输出级别
|
||||
#Rails.logger.level = Logger::INFO
|
||||
|
||||
if(!File.exist?("database"))
|
||||
Dir.mkdir("database")
|
||||
end
|
||||
if(!File.exist?("database/get"))
|
||||
Dir.mkdir("database/get")
|
||||
end
|
||||
if(!File.exist?("database/sql"))
|
||||
Dir.mkdir("database/sql")
|
||||
end
|
||||
if(!File.exist?("database/controller"))
|
||||
Dir.mkdir("database/controller")
|
||||
end
|
||||
|
||||
Rails.logger = Logger.new("database/get/#{Date.today.to_s}.log", "daily")
|
||||
ActiveRecord::Base.logger = Logger.new("database/sql/#{Date.today.to_s}.log", "daily")
|
||||
ActionController::Base.logger = Logger.new("database/controller/#{Date.today.to_s}.log", "daily")
|
||||
end
|
||||
|
||||
end
|
||||
|
|
@ -13,3 +13,16 @@ end
|
|||
|
||||
# Initialize the rails application
|
||||
RedmineApp::Application.initialize!
|
||||
|
||||
#日志格式
|
||||
class Logger
|
||||
def format_message(level, time, progname, msg)
|
||||
"#{time.to_s(:db)} #{level} -- #{msg}\r\n"
|
||||
end
|
||||
end
|
||||
|
||||
#输出日志(database文件夹下get、sql、controller按照日期 分别输出路由信息、SQL语句、调用页面)[影响系统效率使用完请注释掉]
|
||||
#include LoggerHelper
|
||||
#LoggerHelper.OutLogger
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue