Sha256: cf54d146e96021e76a8de370abb616fca91aa92642d9c7c62c5005644bd0f68d
Contents?: true
Size: 1.82 KB
Versions: 3
Compression:
Stored size: 1.82 KB
Contents
# Result contains the request and all the effects that a specific request caused all over the models module OhMyLog module Log class Result attr_reader :effects attr_reader :request def initialize(request) @request = request @effects = calculate_effects end # call this to record the current action done by the user def record! if OhMyLog::Log.configuration.print_log p "REQUEST" p @request.to_s p "RESPONSE" unless @effects.empty? @effects.each {|effect| p effect.to_s} end print_into_log #we can record everything that happend (OPTIONALL) if OhMyLog::Log.configuration.record_history OhMyLog::Log.history << self end #We always save the last operation recorded OhMyLog::Log.last_recorded = self #save this string on file or upload it somewhere end private def print_into_log if OhMyLog::Log.configuration.syslog data = OhMyLog::Log.configuration.syslog.print(ip: OhMyLog::Log.configuration.syslog.public_ip, user: @request.sender, url: @request.path, m: @request.method, s: @request.status, p: @request.params, request_time: @request.date) data.each do |data_info| OhMyLog::Log.configuration.log_instance.info(data_info) end else OhMyLog::Log.configuration.log_instance.info('REQUEST') OhMyLog::Log.configuration.log_instance.info(@request.to_s) OhMyLog::Log.configuration.log_instance.info('RESPONSE') unless @effects.empty? @effects.each {|effect| OhMyLog::Log.configuration.log_instance.info(effect.to_s)} end end def calculate_effects return OhMyLog::Log::targets.map {|target| Effect.new(target)} end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
oh_my_log-1.0.5 | lib/oh_my_log/result.rb |
oh_my_log-1.0.4 | lib/oh_my_log/result.rb |
oh_my_log-1.0.3 | lib/oh_my_log/result.rb |