change debug filepath and make it configurable

This commit is contained in:
chrys 2018-03-22 23:43:38 +01:00
parent 892cefe7e0
commit 73300a920a
8 changed files with 19 additions and 8 deletions

View File

@ -150,6 +150,7 @@ doubleTapTimeout=0.2
[general]
debugLevel=0
debugMode=File
debugFile=/var/log/fenrirscreenreader/fenrir.log
punctuationProfile=default
punctuationLevel=some
respectPunctuationPause=True

View File

@ -152,9 +152,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=File writes to debugFile (Default: /var/log/fenrirscreenreader/fenrir.log)
# debugMode=Print just prints on the screen
debugMode=File
debugFile=/var/log/fenrirscreenreader/fenrir.log
punctuationProfile=default
punctuationLevel=some
respectPunctuationPause=True

View File

@ -153,9 +153,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=File writes to debugFile (Default: /var/log/fenrirscreenreader/fenrir.log)
# debugMode=Print just prints on the screen
debugMode=File
debugFile=/var/log/fenrirscreenreader/fenrir.log
punctuationProfile=default
punctuationLevel=some
respectPunctuationPause=True

View File

@ -101,9 +101,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=File writes to debugFile (Default: /var/log/fenrirscreenreader/fenrir.log)
# debugMode=Print just prints on the screen
debugMode=File
debugFile=/var/log/fenrirscreenreader/fenrir.log
punctuationProfile=default
punctuationLevel=some
respectPunctuationPause=True

View File

@ -152,9 +152,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=File writes to debugFile (Default: /var/log/fenrirscreenreader/fenrir.log)
# debugMode=Print just prints on the screen
debugMode=File
debugFile=/var/log/fenrirscreenreader/fenrir.log
punctuationProfile=default
punctuationLevel=some
respectPunctuationPause=True

View File

@ -3,12 +3,13 @@
from fenrirscreenreader.core import debug
from datetime import datetime
import pathlib, os
class debugManager():
def __init__(self, fileName='/var/log/fenrir.log'):
self._fileName = fileName
def __init__(self, fileName = '/var/log/fenrirscreenreader/fenrir.log'):
self._file = None
self._fileOpened = False
self._fileName = fileName
def initialize(self, environment):
self.env = environment
def shutdown(self):
@ -24,6 +25,9 @@ class debugManager():
if fileName != '':
self._fileName = fileName
if self._fileName != '':
directory = os.path.dirname(self._fileName)
if not os.path.exists(directory):
pathlib.Path(directory).mkdir(parents=True, exist_ok=True)
self._file = open(self._fileName,'a')
self._fileOpened = True

View File

@ -57,6 +57,7 @@ settingsData = {
'general':{
'debugLevel': debug.debugLevel.DEACTIVE,
'debugMode': 'FILE',
'debugFile': '/var/log/fenrirscreenreader/fenrir.log',
'punctuationProfile':'default',
'punctuationLevel': 'some',
'respectPunctuationPause':True,

View File

@ -260,8 +260,6 @@ class settingsManager():
settingsRoot = '/etc/fenrirscreenreader/'
settingsFile = cliArgs.setting
soundRoot = '/usr/share/sounds/fenrirscreenreader/'
environment['runtime']['debug'] = debugManager.debugManager()
environment['runtime']['debug'].initialize(environment)
# get fenrir settings root
if not os.path.exists(settingsRoot):
if os.path.exists(fenrirPath +'/../../config/'):
@ -285,6 +283,9 @@ class settingsManager():
validConfig = environment['runtime']['settingsManager'].loadSettings(settingsFile)
if not validConfig:
return None
environment['runtime']['debug'] = debugManager.debugManager(self.env['runtime']['settingsManager'].getSetting('general','debugFile'))
environment['runtime']['debug'].initialize(environment)
if cliArgs.options != '':
self.parseSettingArgs(cliArgs.options)