diff --git a/config/settings/espeak.settings.conf b/config/settings/espeak.settings.conf index eab064b5..fff11851 100644 --- a/config/settings/espeak.settings.conf +++ b/config/settings/espeak.settings.conf @@ -146,6 +146,7 @@ doubleTapTimeout=0.2 [general] debugLevel=0 +debugMode=File punctuationProfile=default punctuationLevel=some respectPunctuationPause=True diff --git a/config/settings/settings.conf b/config/settings/settings.conf index 68f7e7ab..4ba27fbc 100644 --- a/config/settings/settings.conf +++ b/config/settings/settings.conf @@ -148,6 +148,10 @@ doubleTapTimeout=0.2 [general] debugLevel=0 +# debugMode sets where the debug output should send to: +# debugMode=File writes to /var/log/fenrir.log +# debugMode=Print just prints on the screen +debugMode=File punctuationProfile=default punctuationLevel=some respectPunctuationPause=True diff --git a/config/settings/settings.conf.storm b/config/settings/settings.conf.storm index 09af4df0..e8114fc8 100644 --- a/config/settings/settings.conf.storm +++ b/config/settings/settings.conf.storm @@ -42,7 +42,6 @@ fenrirMaxPitch=99 fenrirMinRate=80 fenrirMaxRate=890 - [braille] enabled=False driver=dummyDriver @@ -99,6 +98,10 @@ doubleTapTimeout=0.2 [general] debugLevel=1 +# debugMode sets where the debug output should send to: +# debugMode=File writes to /var/log/fenrir.log +# debugMode=Print just prints on the screen +debugMode=File punctuationProfile=default punctuationLevel=some respectPunctuationPause=True diff --git a/src/fenrir/core/debug.py b/src/fenrir/core/debug.py index 271c221b..72b5a61a 100644 --- a/src/fenrir/core/debug.py +++ b/src/fenrir/core/debug.py @@ -1,8 +1,6 @@ #!/usr/bin/python -# Debugger module for the Fenrir screen reader. from enum import Enum -from datetime import datetime class debugLevel(Enum): DEACTIVE = 0 @@ -13,60 +11,3 @@ class debugLevel(Enum): return self.value def __str__(self): return self.name - -class debug(): - def __init__(self, fileName='/var/log/fenrir.log'): - self._fileName = fileName - self._file = None - self._fileOpened = False - def initialize(self, environment): - self.env = environment - def shutdown(self): - self.closeDebugFile() - def __del__(self): - try: - self.shutdown() - except: - pass - - def openDebugFile(self, fileName = ''): - self._fileOpened = False - if fileName != '': - self._fileName = fileName - if self._fileName != '': - self._file = open(self._fileName,'a') - self._fileOpened = True - - def writeDebugOut(self, text, level = debugLevel.DEACTIVE, onAnyLevel=False): - if (self.env['runtime']['settingsManager'].getSettingAsInt('general','debugLevel') < int(level)) and \ - not (onAnyLevel and self.env['runtime']['settingsManager'].getSettingAsInt('general','debugLevel') > int(debugLevel.DEACTIVE)) : - if self._fileOpened: - self.closeDebugFile() - return - else: - if not self._fileOpened: - self.openDebugFile() - if onAnyLevel: - msg = 'ANY '+ str(level) + ' ' + str(datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S.%f')) - else: - msg = str(level) +' ' + str(datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S.%f') -) - msg += ': ' + text - print(msg) - self._file.write(msg + '\n') - - - def closeDebugFile(self): - if not self._fileOpened: - return False - if self._file != None: - self._file.close() - self._fileOpened = False - return True - - def getDebugFile(self): - return self._fileName - - def setDebugFile(self, fileName): - self.closeDebugFile() - self._fileName = fileName diff --git a/src/fenrir/core/fenrirManager.py b/src/fenrir/core/fenrirManager.py index c47fd5a6..d6193199 100644 --- a/src/fenrir/core/fenrirManager.py +++ b/src/fenrir/core/fenrirManager.py @@ -36,7 +36,8 @@ class fenrirManager(): parser = argparse.ArgumentParser(description="Fenrir Help") parser.add_argument('-s', '--setting', metavar='SETTING-FILE', default='/etc/fenrir/settings/settings.conf', help='Use a specified settingsfile') parser.add_argument('-o', '--options', metavar='SECTION#SETTING=VALUE,..', default='', help='Overwrite options in given settings file') - parser.add_argument('-d', '--debug', action='store_true', help='Turns on Debugmode') + parser.add_argument('-d', '--debug', action='store_true', help='Turns on Debugmode') + parser.add_argument('-p', '--print', action='store_true', help='Print debug messages on screen') try: args = parser.parse_args() except Exception as e: diff --git a/src/fenrir/core/settingsData.py b/src/fenrir/core/settingsData.py index c94df2cf..27c05d24 100644 --- a/src/fenrir/core/settingsData.py +++ b/src/fenrir/core/settingsData.py @@ -54,6 +54,7 @@ settingsData = { }, 'general':{ 'debugLevel': debug.debugLevel.DEACTIVE, + 'debugMode': 'FILE', 'punctuationProfile':'default', 'punctuationLevel': 'some', 'respectPunctuationPause':True, diff --git a/src/fenrir/core/settingsManager.py b/src/fenrir/core/settingsManager.py index 58272da8..1d33614c 100644 --- a/src/fenrir/core/settingsManager.py +++ b/src/fenrir/core/settingsManager.py @@ -9,6 +9,7 @@ currentdir = os.path.dirname(os.path.realpath(os.path.abspath(inspect.getfile(in fenrirPath = os.path.dirname(currentdir) from configparser import ConfigParser +from core import debugManager from core import processManager from core import eventManager from core import inputManager @@ -256,7 +257,7 @@ class settingsManager(): settingsRoot = '/etc/fenrir/' settingsFile = cliArgs.setting soundRoot = '/usr/share/sounds/fenrir/' - environment['runtime']['debug'] = debug.debug() + environment['runtime']['debug'] = debugManager.debugManager() environment['runtime']['debug'].initialize(environment) # get fenrir settings root if not os.path.exists(settingsRoot): @@ -285,8 +286,10 @@ class settingsManager(): if cliArgs.options != '': self.parseSettingArgs(cliArgs.options) if cliArgs.debug: - self.setOptionArgDict('general', 'debugLevel', 3) - + self.setOptionArgDict('general', 'debugLevel', 3) + if cliArgs.print: + self.setOptionArgDict('general', 'debugLevel', 3) + self.setOptionArgDict('general', 'debugMode', 'PRINT') self.setFenrirKeys(self.getSetting('general','fenrirKeys')) self.setScriptKeys(self.getSetting('general','scriptKeys'))