Skip to content

Commit

Permalink
Merge pull request #91 from opengisch/log_plusplus
Browse files Browse the repository at this point in the history
Further improvements in the logs
  • Loading branch information
suricactus authored Apr 21, 2024
2 parents 412b143 + c6d51af commit 4cec1a6
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions open_alaqs/core/alaqsutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"""
import os
import sys
import traceback

from qgis.core import Qgis, QgsMessageLog
from qgis.utils import spatialite_connect
Expand Down Expand Up @@ -38,25 +39,22 @@ def print_error(function_name, exception_object, e_object, log=logger):
pass

exc_type, exc_obj, exc_tb = sys.exc_info()
error = "[-] Error in %s() [line %d]: %s %s" % (
error_msg = "[-] Error in %s() [line %d]: %s %s" % (
function_name,
exc_tb.tb_lineno,
exc_type,
exc_obj,
)

if "object has been deleted" in str(exc_obj):
return None
else:
log.error(error)
log.error(error_msg, exc_info=exception_object)

QgsMessageLog.logMessage(
f"{str(e_object)}:\n{exc_tb}",
(error_msg + "\n" + "".join(traceback.format_exception(e_object))),
tag="Open ALAQS",
level=Qgis.MessageLevel.Critical,
)

return error
return error_msg


# ===========================================================
Expand Down

0 comments on commit 4cec1a6

Please sign in to comment.