OpenShift::UserActionLog

Attributes

logger[RW]

Public Class Methods

action(action, success=true, description=nil, args={}, detailed_description=nil) click to toggle source
# File lib/openshift/user_action_log.rb, line 15
def self.action(action, success=true, description=nil, args={}, detailed_description=nil)
  return unless logger

  result = success ? "SUCCESS" : "FAILURE"
  description = (description || "").strip
  detailed_description = (detailed_description || "").strip
  time_obj = Time.new
  date = time_obj.strftime("%Y-%m-%d")
  time = time_obj.strftime("%H:%M:%S")

  message = "#{result} DATE=#{date} TIME=#{time} ACTION=#{action} REQ_ID=#{Thread.current[:user_action_log_uuid]}"
  auth = " USER_ID=#{Thread.current[:user_action_log_user_id].to_s} LOGIN=#{Thread.current[:user_action_log_identity_id].to_s}"
  extra = args.map{|k,v| " #{k}=#{v}"}.join

  # We are not logging the detailed multi-line logs in the user action logger 
  logger.info("#{message}#{auth}#{extra} #{description}")

  unless Rails.env.production?
    # Using a block prevents the message in the block from being executed 
    # if the log_level is lower than the one set for the logger
    Rails.logger.add(Logger::DEBUG){ "  #{result} ACTION=#{action}#{auth}#{extra} #{description} #{detailed_description}" }
  end
end
begin_request(request) click to toggle source
# File lib/openshift/user_action_log.rb, line 3
def self.begin_request(request)
  Thread.current[:user_action_log_uuid] = request ? request.uuid : nil
end
end_request() click to toggle source
# File lib/openshift/user_action_log.rb, line 6
def self.end_request
  begin_request(nil)
  with_user(nil, nil)
end
with_user(id, login) click to toggle source
# File lib/openshift/user_action_log.rb, line 10
def self.with_user(id, login)
  Thread.current[:user_action_log_user_id] = id
  Thread.current[:user_action_log_identity_id] = login
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.