Sha256: ea9142628784f459e5e58791fe0b14b917e44c8680e274674997c03c1b2f39e7

Contents?: true

Size: 1.37 KB

Versions: 30

Compression:

Stored size: 1.37 KB

Contents

#--
# Wmap
#
# A pure Ruby library for Internet web application discovery and tracking.
#
# Copyright (c) 2012-2015 Yang Li <yang.li@owasp.org>
#++


module Wmap
 module Utils	
  # Module to log debugging and other messages
  module Logger	
	extend self
	# Append information into the log file for the trouble-shooting purpose
	def wlog (obj, agent, file)
		puts "Writing #{obj} into log file: #{file}" if @verbose
		begin
			return false if obj.nil? 
			# 01/27/2015, implementing singleton pattern for the logger
			@@f=File.open(file,'a')	
			timestamp=Time.now
			case obj
			when Array
				if obj.size >= 0
					@@f.write "#{timestamp}: #{agent}: \n"
					obj.map { |x| @@f.write "  #{x}\n" }
					puts "The list is successfully saved into the log file: #{file} " if @verbose
				end
			when Hash
				if obj.length >= 0
					@@f.write "#{timestamp}: #{agent}: \n"
					obj.each_value { |value| @@f.write "  #{value}\n" }
					puts "The hash is successfully saved into the log file: #{file} " if @verbose
				end
			when String
				@@f.write "#{timestamp}: #{agent}: #{obj}\n"
				puts "The string is successfully saved into the log file: #{file} " if @verbose
			else
				#do nothing
				puts "Un-handled exception on: #{obj}" if @verbose
			end
			@@f.close
			return true
		rescue => ee
			puts "Exception on method #{__method__}: #{ee}" if @verbose
			return false
		end	
	end
	
  end	
 end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
wmap-2.7.9 lib/wmap/utils/logger.rb
wmap-2.7.7 lib/wmap/utils/logger.rb
wmap-2.7.6 lib/wmap/utils/logger.rb
wmap-2.7.2 lib/wmap/utils/logger.rb
wmap-2.7.1 lib/wmap/utils/logger.rb
wmap-2.7.0 lib/wmap/utils/logger.rb
wmap-2.6.9 lib/wmap/utils/logger.rb
wmap-2.6.8 lib/wmap/utils/logger.rb
wmap-2.6.7 lib/wmap/utils/logger.rb
wmap-2.6.6 lib/wmap/utils/logger.rb
wmap-2.6.5 lib/wmap/utils/logger.rb
wmap-2.6.4 lib/wmap/utils/logger.rb
wmap-2.6.3 lib/wmap/utils/logger.rb
wmap-2.6.2 lib/wmap/utils/logger.rb
wmap-2.6.1 lib/wmap/utils/logger.rb
wmap-2.6.0 lib/wmap/utils/logger.rb
wmap-2.5.9 lib/wmap/utils/logger.rb
wmap-2.5.8 lib/wmap/utils/logger.rb
wmap-2.5.7 lib/wmap/utils/logger.rb
wmap-2.5.6 lib/wmap/utils/logger.rb