Module: Log

Defined in:
lib/rubyhacks.rb

Constant Summary collapse

@@log_file =
'log.txt'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.clean_upObject



696
697
698
699
# File 'lib/rubyhacks.rb', line 696

def self.clean_up
	return unless @@log_file
	File.delete @@log_file if FileTest.exist? @@log_file
end

.log(*messages) ⇒ Object



701
702
703
704
705
706
707
708
709
710
# File 'lib/rubyhacks.rb', line 701

def Log.log(*messages)
#		p 'wanting to log', @@log_file
	return nil unless @@log_file
# 		return
# 		return unless @@log_file
#		puts 'logging'
	messages.each do |message|
		File.open(@@log_file, 'a'){|file| file.puts message}
	end
end

.log_fileObject



688
689
690
# File 'lib/rubyhacks.rb', line 688

def self.log_file
	@@log_file
end

.log_file=(file) ⇒ Object



692
693
694
# File 'lib/rubyhacks.rb', line 692

def self.log_file=(file)
	@@log_file=file
end

.logf(func_name) ⇒ Object



717
718
719
# File 'lib/rubyhacks.rb', line 717

def Log.logf(func_name)
	log("Function: " + func_name + ": " + self.to_s)
end

.logi(*messages) ⇒ Object



737
738
739
740
741
742
# File 'lib/rubyhacks.rb', line 737

def Log.logi(*messages)
	return nil unless @@log_file
	messages.each do |message|
		File.open(@@log_file, 'a'){|file| file.puts message.inspect}
	end
end

.logtObject



755
756
757
# File 'lib/rubyhacks.rb', line 755

def Log.logt
	log("Traceback \n" + caller.join("\n"))
end

Instance Method Details

#log(*messages) ⇒ Object



712
713
714
715
# File 'lib/rubyhacks.rb', line 712

def log(*messages)
	return nil unless @@log_file
	Log.log(*messages)
end

#logdObject



759
760
761
# File 'lib/rubyhacks.rb', line 759

def logd
	log("Current Directory: " + Dir.pwd)
end

#logf(func_name) ⇒ Object



721
722
723
724
725
726
727
# File 'lib/rubyhacks.rb', line 721

def logf(func_name)
# 		p func_name
# 		p "Function: " + func_name.to_s + ": " + self.class.to_s
	message = "Function: " + func_name.to_s + ": " + self.class.to_s
# 		p message.class
	log(message)
end

#logfc(func_name) ⇒ Object



729
730
731
732
733
734
735
# File 'lib/rubyhacks.rb', line 729

def logfc(func_name)
# 		p func_name
# 		p "Function: " + func_name.to_s + ": " + self.class.to_s
	message = "Function: " + func_name.to_s + ": complete :" + self.class.to_s 
# 		p message.class
	log(message)
end

#logi(*messages) ⇒ Object



744
745
746
747
748
749
# File 'lib/rubyhacks.rb', line 744

def logi(*messages)
	return nil unless @@log_file
	messages.each do |message|
		File.open(@@log_file, 'a'){|file| file.puts message.inspect}
	end
end

#logtObject



751
752
753
# File 'lib/rubyhacks.rb', line 751

def logt
	log("Traceback \n" + caller.join("\n"))
end