update debug

This commit is contained in:
chrys87 2016-07-08 11:56:42 +02:00 committed by GitHub
parent 13d9252c23
commit ff72fbd1d7

View File

@ -2,28 +2,40 @@
# Debugger module for the Fenrir screen reader.
ERROR = 0
WARNING = 1
INFO = 2
DEACTIVE = 0
ERROR = 1
WARNING = 2
INFO = 3
class debug():
def __init__(self, fileName='/var/log/fenrir.log', level = ERROR):
self._level = level
self._fileName= fileName
self._file = open(self._fileName,'w')
self._fileOpened = True
self._fileName = fileName
self._file = ''
self._fileOpened = False
def openDebugFile(self, fileName = ''):
self._fileOpened = False
if fileName != '':
self._fileName = fileName
if self._fileName != '':
self.file = open(self._fileName,'w')
self._fileOpened = True
def writeLog(self, text, level = ERROR):
def writeDebugOut(self, envirionment, text):
if not envirionment['generalInformation']['debugEnabled']:
if self._fileOpened:
self.closeDebugFile()
return
else:
if not self._fileOpened:
self.openDebugFile()
self.writeLog(environment, text):
def writeLog(self, environment, text):
if not self._fileOpened:
return False
if self._level < level:
if self._level < envirionment['generalInformation']['debugLevel']:
return False
self._file.write(text + '\n')
return True
@ -45,6 +57,9 @@ class debug():
return self._fileName
def setDebugFile(self, fileName):
self._fileName = fileName
self.closeDebugFile()
if self._fileOpened:
self.openDebugFile(self, fileName):