Update application_controller.rb

This commit is contained in:
TianLun Song 2025-01-27 09:42:08 +08:00 committed by GitHub
parent 111fd85ebb
commit 16ee512b0c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -43,27 +43,12 @@ class ApplicationController < ActionController::Base
def log_browser_info
# 构建详细的浏览器信息
browser_info = {
user_agent: request.user_agent,
path: request.path,
browser_name: browser.name,
browser_version: browser.version,
platform: browser.platform.name,
device: browser.device.name,
mobile: browser.mobile?,
tablet: browser.tablet?,
bot: browser.bot?,
matched_patterns: matched_browser_patterns,
timestamp: Time.current
}
# 使用 Rails.logger 记录信息both development and production
Rails.logger.info "Browser Info: #{browser_info.to_json}"
Rails.logger.info "User Agent: #{request.user_agent}"
# 如果是被拦截的浏览器,记录额外信息
unless browser_allowed?
Rails.logger.warn "Browser Blocked: #{browser_info.to_json}"
end
# unless browser_allowed?
# Rails.logger.warn "Browser Blocked: #{browser_info.to_json}"
# end
end
protected