Sha256: c00be3e52a44ede6928cca1bc43c90cc3c9c017427da75b21ab8adb520d4eb92

Contents?: true

Size: 1.26 KB

Versions: 6

Compression:

Stored size: 1.26 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
		return false if obj.nil?
		@@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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
wmap-2.8.6 lib/wmap/utils/logger.rb
wmap-2.8.5 lib/wmap/utils/logger.rb
wmap-2.8.4 lib/wmap/utils/logger.rb
wmap-2.8.3 lib/wmap/utils/logger.rb
wmap-2.8.2 lib/wmap/utils/logger.rb
wmap-2.8.1 lib/wmap/utils/logger.rb