logger.py 375 B

123456789101112
  1. import datetime
  2. import time
  3. import inspect
  4. import sys
  5. class Logger:
  6. CRITICAL, WARNING, INFO = range(3)
  7. levels = ['CRITICAL', 'WARNING', 'INFO']
  8. def write(self, level, line):
  9. f = open('pylog-'+str(time.strftime("%d-%m-%Y"))+'.log', "a")
  10. f.write(str(datetime.datetime.now())+ " (" + inspect.stack()[1][3] + ") " + str(Logger.levels[level]) + ": " + line + '\n')