Advertisement
QuantumWarpCode

Python Log File Creation Classes

Nov 9th, 2014
441
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.61 KB | None | 0 0
  1. import time, datetime
  2.  
  3. class string(object):
  4.    
  5.     def removeChars(self, string, charArray):
  6.        
  7.         for i in range (0, len(charArray)):
  8.             string = string.replace(charArray[i], "")
  9.        
  10.         return string
  11.  
  12. class log(object):
  13.    
  14.     def fileOpen(self, file):
  15.        
  16.         self.file = open(file,"a")
  17.    
  18.     def addLine(self, line):
  19.        
  20.         self.file.write(str(line) + "\n")
  21.    
  22.     def addLineDT(self, line):
  23.        
  24.         time = datetime.datetime.now()
  25.         print(time)
  26.         self.addLine(str(time) + str(line))
  27.    
  28.     def addLinePrint(self, line):
  29.        
  30.         self.file.write(str(line) + "\n")
  31.         print(line)
  32.    
  33.     def fileClose(self):
  34.        
  35.         self.file.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement