Skip to content

Commit d07defe

Browse files
MartinThomaferdnyc
andauthored
Adjust log levels (#3724)
* Adjust log levels Co-authored-by: Frank Dana <[email protected]>
1 parent f48a9c5 commit d07defe

14 files changed

+86
-91
lines changed

src/classes/app.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,13 @@ def __init__(self, *args, mode=None):
9191
reroute_output()
9292
except ImportError as ex:
9393
tb = traceback.format_exc()
94-
log.error('OpenShotApp::Import Error: %s' % str(ex))
94+
log.error('OpenShotApp::Import Error', exc_info=1)
9595
QMessageBox.warning(None, "Import Error",
9696
"Module: %(name)s\n\n%(tb)s" % {"name": ex.name, "tb": tb})
9797
# Stop launching and exit
9898
raise
99-
except Exception as ex:
100-
log.error('OpenShotApp::Init Error: %s' % str(ex))
99+
except Exception:
100+
log.error('OpenShotApp::Init Error', exc_info=1)
101101
sys.exit()
102102

103103
# Log some basic system info
@@ -115,7 +115,7 @@ def __init__(self, *args, mode=None):
115115
log.info("qt5 version: %s" % QT_VERSION_STR)
116116
log.info("pyqt5 version: %s" % PYQT_VERSION_STR)
117117
except Exception:
118-
log.warning("Error displaying dependency/system details", exc_info=1)
118+
log.debug("Error displaying dependency/system details", exc_info=1)
119119

120120
# Setup application
121121
self.setApplicationName('openshot')
@@ -175,7 +175,7 @@ def __init__(self, *args, mode=None):
175175
os.unlink(TEST_PATH_FILE)
176176
os.rmdir(TEST_PATH_DIR)
177177
except PermissionError as ex:
178-
log.error('Failed to create PERMISSION/test.osp file (likely permissions error): %s' % TEST_PATH_FILE)
178+
log.error('Failed to create PERMISSION/test.osp file (likely permissions error): %s' % TEST_PATH_FILE, exc_info=1)
179179
QMessageBox.warning(None, _("Permission Error"),
180180
_("%(error)s. Please delete <b>%(path)s</b> and launch OpenShot again." % {"error": str(ex), "path": info.USER_PATH}))
181181
# Stop launching and exit
@@ -199,8 +199,8 @@ def __init__(self, *args, mode=None):
199199
font = QFont(font_family)
200200
font.setPointSizeF(10.5)
201201
QApplication.setFont(font)
202-
except Exception as ex:
203-
log.error("Error setting Ubuntu-R.ttf QFont: %s" % str(ex))
202+
except Exception:
203+
log.debug("Error setting Ubuntu-R.ttf QFont", exc_info=1)
204204

205205
# Set Experimental Dark Theme
206206
if self.settings.get("theme") == "Humanity: Dark":
@@ -272,8 +272,8 @@ def run(self):
272272
try:
273273
from classes.logger import log
274274
self.settings.save()
275-
except Exception as ex:
276-
log.error("Couldn't save user settings on exit.\n{}".format(ex))
275+
except Exception:
276+
log.error("Couldn't save user settings on exit.", exc_info=1)
277277

278278
# return exit result
279279
return res
@@ -291,4 +291,4 @@ def onLogTheEnd():
291291
log.info("================================================")
292292
except Exception:
293293
from classes.logger import log
294-
log.warning('Failed to write session ended log')
294+
log.debug('Failed to write session ended log')

src/classes/json_data.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,8 @@ def read_from_file(self, file_path, path_mode="ignore"):
193193
log.error(str(ex))
194194
raise
195195
except Exception as ex:
196-
msg = ("Couldn't load {} file: {}".format(self.data_type, ex))
197-
log.error(msg)
196+
msg = "Couldn't load {} file".format(self.data_type)
197+
log.error(msg, exc_info=1)
198198
raise Exception(msg) from ex
199199
msg = ()
200200
log.warning(msg)
@@ -210,7 +210,7 @@ def write_to_file(self, file_path, data, path_mode="ignore", previous_path=None)
210210
with open(file_path, 'w', encoding='utf-8') as f:
211211
f.write(contents)
212212
except Exception as ex:
213-
msg = ("Couldn't save {} file:\n{}\n{}".format(self.data_type, file_path, ex))
213+
msg = "Couldn't save {} file:\n{}\n{}".format(self.data_type, file_path, ex)
214214
log.error(msg)
215215
raise Exception(msg)
216216

src/classes/language.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def get_all_languages():
145145
country_name = QLocale(locale_name).nativeCountryName().title()
146146
all_languages.append((locale_name, native_lang_name, country_name))
147147
except:
148-
log.warning('Failed to parse language for %s' % locale_name)
148+
log.debug('Failed to parse language for %s', locale_name)
149149

150150
# Return list
151151
return all_languages

src/classes/metrics.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@
6464
# Get the distro name and version (if any)
6565
linux_distro = "-".join(platform.linux_distribution())
6666

67-
except Exception as Ex:
68-
log.error("Error determining OS version in metrics.py")
67+
except Exception:
68+
log.debug("Error determining OS version", exc_info=1)
6969

7070
# Build user-agent
7171
user_agent = "Mozilla/5.0 (%s) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36" % os_version
@@ -173,8 +173,8 @@ def send_metric(params):
173173
r = requests.get(url, headers={"user-agent": user_agent}, verify=False)
174174
log.info("Track metric: [%s] %s | (%s bytes)" % (r.status_code, r.url, len(r.content)))
175175

176-
except Exception as Ex:
177-
log.error("Failed to Track metric: %s" % (Ex))
176+
except Exception as ex:
177+
log.warning("Failed to track metric", exc_info=1)
178178

179179
# Wait a moment, so we don't spam the requests
180180
time.sleep(0.25)
@@ -199,7 +199,6 @@ def send_exception(stacktrace, source):
199199
# Send exception HTTP data
200200
try:
201201
r = requests.post(url, data=data, headers={"user-agent": user_agent, "content-type": "application/x-www-form-urlencoded"}, verify=False)
202-
log.info("Track exception: [%s] %s | %s" % (r.status_code, r.url, r.text))
203-
204-
except Exception as Ex:
205-
log.error("Failed to Track exception: %s" % (Ex))
202+
log.info("Track exception: [%s] %s | %s", r.status_code, r.url, r.text)
203+
except Exception:
204+
log.warning("Failed to track exception", exc_info=1)

src/classes/project_data.py

+16-16
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ def __init__(self):
6060
self.new()
6161

6262
def needs_save(self):
63-
"""Returns if project data Has unsaved changes"""
63+
"""Returns if project data has unsaved changes"""
6464
return self.has_unsaved_changes
6565

6666
def get(self, key):
67-
""" Get copied value of a given key in data store """
67+
"""Get copied value of a given key in data store"""
6868

6969
# Verify key is valid type
7070
if not key:
71-
log.warning("Cannot get empty key.")
71+
log.warning("ProjectDataStore cannot get empty key.")
7272
return None
7373
if not isinstance(key, list):
7474
key = [key]
@@ -149,10 +149,10 @@ def _set(self, key, values=None, add=False, partial_update=False, remove=False):
149149

150150
# Verify key is valid type
151151
if not isinstance(key, list):
152-
log.warning("_set() key must be a list. key: {}".format(key))
152+
log.warning("_set() key must be a list. key=%s", key)
153153
return None
154154
if not key:
155-
log.warning("Cannot set empty key.")
155+
log.warning("Cannot set empty key (key=%s)", key)
156156
return None
157157

158158
# Get reference to internal data structure
@@ -255,8 +255,8 @@ def new(self):
255255
if os.path.exists(info.USER_DEFAULT_PROJECT):
256256
try:
257257
self._data = self.read_from_file(info.USER_DEFAULT_PROJECT)
258-
except (FileNotFoundError, PermissionError) as ex:
259-
log.warning("Unable to load user project defaults from {}: {}".format(info.USER_DEFAULT_PROJECT, ex))
258+
except (FileNotFoundError, PermissionError):
259+
log.warning("Unable to load user project defaults from %s", info.USER_DEFAULT_PROJECT, exc_info=1)
260260
except Exception:
261261
raise
262262
else:
@@ -533,10 +533,10 @@ def read_legacy_project_file(self, file_path):
533533
# Keep track of new ids and old ids
534534
file_lookup[item.unique_id] = file
535535

536-
except Exception as ex:
537-
# Handle exception quietly
538-
msg = ("%s is not a valid video, audio, or image file: %s" % (item.name, str(ex)))
539-
log.error(msg)
536+
except Exception:
537+
log.error("%s is not a valid video, audio, or image file",
538+
item.name,
539+
exc_info=1)
540540
failed_files.append(item.name)
541541

542542
# Delete all tracks
@@ -693,10 +693,10 @@ def read_legacy_project_file(self, file_path):
693693
# Increment track counter
694694
track_counter += 1
695695

696-
except Exception as ex:
696+
except Exception:
697697
# Error parsing legacy contents
698-
msg = "Failed to load project file %(path)s: %(error)s" % {"path": file_path, "error": ex}
699-
log.error(msg)
698+
msg = "Failed to load legacy project file %(path)s" % {"path": file_path}
699+
log.error(msg, exc_info=1)
700700
raise RuntimeError(msg) from ex
701701

702702
# Show warning if some files failed to load
@@ -891,8 +891,8 @@ def move_temp_paths_to_project_folder(self, file_path, previous_path=None):
891891
clip["reader"]["path"] = reader_paths[file_id]
892892
log.info("Updated clip {} path for file {}".format(clip["id"], file_id))
893893

894-
except Exception as ex:
895-
log.error("Error while moving temp paths to project assets folder {}: {}".format(asset_path, ex))
894+
except Exception:
895+
log.error("Error while moving temp paths to project assets folder %s", asset_path, exc_info=1)
896896

897897
def add_to_recent_files(self, file_path):
898898
""" Add this project to the recent files list """

src/windows/about.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ def __init__(self):
7474
if changelog_file.read():
7575
self.btnchangelog.setVisible(True)
7676
break
77-
except:
78-
log.warning('Failed to parse log file %s with encoding %s' % (changelog_path, encoding_name))
77+
except Exception:
78+
log.debug('Failed to parse log file %s with encoding %s', changelog_path, encoding_name)
7979

8080
create_text = _('Create &amp; Edit Amazing Videos and Movies')
8181
description_text = _('OpenShot Video Editor 2.x is the next generation of the award-winning <br/>OpenShot video editing platform.')
@@ -268,8 +268,8 @@ def __init__(self):
268268
'author': line[20:45].strip(),
269269
'subject': line[45:].strip() })
270270
break
271-
except:
272-
log.warning('Failed to parse log file %s with encoding %s' % (changelog_path, encoding_name))
271+
except Exception:
272+
log.debug('Failed to parse log file %s with encoding %s', changelog_path, encoding_name)
273273
self.openshot_qt_ListView = ChangelogTreeView(commits=changelog_list, commit_url="https://github.com/OpenShot/openshot-qt/commit/%s/")
274274
self.vbox_openshot_qt.addWidget(self.openshot_qt_ListView)
275275
self.txtChangeLogFilter_openshot_qt.textChanged.connect(partial(self.Filter_Triggered, self.txtChangeLogFilter_openshot_qt, self.openshot_qt_ListView))
@@ -288,8 +288,8 @@ def __init__(self):
288288
'author': line[20:45].strip(),
289289
'subject': line[45:].strip() })
290290
break
291-
except:
292-
log.warning('Failed to parse log file %s with encoding %s' % (changelog_path, encoding_name))
291+
except Exception:
292+
log.debug('Failed to parse log file %s with encoding %s', changelog_path, encoding_name)
293293
self.libopenshot_ListView = ChangelogTreeView(commits=changelog_list, commit_url="https://github.com/OpenShot/libopenshot/commit/%s/")
294294
self.vbox_libopenshot.addWidget(self.libopenshot_ListView)
295295
self.txtChangeLogFilter_libopenshot.textChanged.connect(partial(self.Filter_Triggered, self.txtChangeLogFilter_libopenshot, self.libopenshot_ListView))
@@ -310,8 +310,8 @@ def __init__(self):
310310
'author': line[20:45].strip(),
311311
'subject': line[45:].strip() })
312312
break
313-
except:
314-
log.warning('Failed to parse log file %s with encoding %s' % (changelog_path, encoding_name))
313+
except Exception:
314+
log.debug('Failed to parse log file %s with encoding %s', changelog_path, encoding_name)
315315
self.libopenshot_audio_ListView = ChangelogTreeView(commits=changelog_list, commit_url="https://github.com/OpenShot/libopenshot-audio/commit/%s/")
316316
self.vbox_libopenshot_audio.addWidget(self.libopenshot_audio_ListView)
317317
self.txtChangeLogFilter_libopenshot_audio.textChanged.connect(partial(self.Filter_Triggered, self.txtChangeLogFilter_libopenshot_audio, self.libopenshot_audio_ListView))

src/windows/animated_title.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -130,5 +130,5 @@ def clear_effect_controls(self):
130130
try:
131131
self.settingsContainer.layout().removeWidget(child)
132132
child.deleteLater()
133-
except:
134-
log.warning('Failed to remove child widget for effect controls')
133+
except Exception:
134+
log.debug('Failed to remove child widget for effect controls')

0 commit comments

Comments
 (0)