Merge branch 'Logging_Fixes' into 'master'

Clean up logging

See merge request openlp/openlp!392
This commit is contained in:
Tim Bentley 2022-02-01 20:01:27 +00:00
commit f711a64dc5
2 changed files with 5 additions and 6 deletions

View File

@ -308,15 +308,13 @@ def set_up_logging(log_path):
logfile = logging.FileHandler(file_path, 'w', encoding='UTF-8')
logfile.setFormatter(logging.Formatter('%(asctime)s %(threadName)s %(name)-55s %(levelname)-8s %(message)s'))
log.addHandler(logfile)
if log.isEnabledFor(logging.DEBUG):
print('Logging to: {name}'.format(name=file_path))
print(f'Logging to: {file_path} and level {log.level}')
def main():
"""
The main function which parses command line options and then runs
"""
log.debug('Entering function - main')
args = parse_options()
qt_args = ['--disable-web-security']
# qt_args = []
@ -385,6 +383,7 @@ def main():
Registry.create()
settings = Settings()
Registry().register('settings', settings)
log.warning(f'Arguments passed {args}')
# Need settings object for the threads.
settings_thread = Settings()
Registry().register('settings_thread', settings_thread)

View File

@ -642,7 +642,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow, LogMixin, RegistryPropert
# We have -disable-web-security added by our code.
# If a file is passed in we will have that as well so count of 2
# If not we need to see if we want to use the previous file.so count of 1
self.log_info(self.application.args)
self.log_warning(self.application.args)
if self.application.args and len(self.application.args) > 1:
self.open_cmd_line_files(self.application.args)
elif self.settings.value('core/auto open'):
@ -1412,8 +1412,8 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow, LogMixin, RegistryPropert
:param list[str] args: List of remaining positional arguments
"""
for arg in args:
self.log_info(arg)
self.log_warning(arg)
file_name = os.path.expanduser(arg)
if os.path.isfile(file_name):
self.log_info("File name found")
self.log_warning("File name found")
self.service_manager_contents.load_file(Path(file_name))