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



707
708
709
710
# File 'lib/rubyhacks.rb', line 707

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

.log(*messages) ⇒ Object



712
713
714
715
716
717
718
719
720
721
# File 'lib/rubyhacks.rb', line 712

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



699
700
701
# File 'lib/rubyhacks.rb', line 699

def self.log_file
  @@log_file
end

.log_file=(file) ⇒ Object



703
704
705
# File 'lib/rubyhacks.rb', line 703

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

.logf(func_name) ⇒ Object



728
729
730
# File 'lib/rubyhacks.rb', line 728

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

.logi(*messages) ⇒ Object



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

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



766
767
768
# File 'lib/rubyhacks.rb', line 766

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

Instance Method Details

#log(*messages) ⇒ Object



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

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

#logdObject



770
771
772
# File 'lib/rubyhacks.rb', line 770

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

#logf(func_name) ⇒ Object



732
733
734
735
736
737
738
# File 'lib/rubyhacks.rb', line 732

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



740
741
742
743
744
745
746
# File 'lib/rubyhacks.rb', line 740

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



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

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



762
763
764
# File 'lib/rubyhacks.rb', line 762

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