pollish up debug framework

This commit is contained in:
chrys 2016-07-07 00:56:30 +02:00
parent 03b81fcaef
commit e5641f80d7

View File

@ -1,21 +1,49 @@
#!/usr/bin/python #!/usr/bin/python
# Debugger module for the Fenrir screen reader. # Debugger module for the Fenrir screen reader.
ERROR = 0
WARNING = 1
INFO = 2
class debug(): class debug():
def __init__(self, level=0i, debugFile=/var/log/fenrir.log) def __init__(self, fileName='/var/log/fenrir.log', level = ERROR):
self.debugLevel = level self._level = level
self._fileName= fileName
self._file = open(self._fileName,'w')
self._fileOpened = True
def get_debug_level(): def openDebugFile(self, fileName = ''):
return debugLevel if fileName != '':
self._fileName = fileName
if self._fileName != '':
self.file = open(self._fileName,'w')
self._fileOpened = True
def set_debug_level(level): def writeLog(self, text, level = ERROR):
debugLevel = level if not self._fileOpened:
return False
if self._level < level:
return False
self._file.write(text + '\n')
return True
def get_debug_file(): def closeDebugFile(self):
return debugFile if not self._fileOpened:
return False
self._file.close()
self._fileOpened = False
return True
def set_debug_file(file): def getDebugLevel(self):
debugFile = file return self._level
def setDebugLevel(self, level):
self._level = level
def getDebugFile(self):
return self._fileName
def setDebugFile(self, fileName):
self._fileName = fileName