Skip to content

Commit

Permalink
Fix exception and release 1.6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustry committed Sep 17, 2021
1 parent eeaceb0 commit 2584efe
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@

## Unreleased

## 1.6.1 - 2021-09-17

* Fix error in some deployments environment, regression from 1.6.0

## 1.6.0 - 2021-09-15

* Add some logs in the plugin to make it easier to debug
* Add a new environment variable `DEBUG_WFSOUTPUTEXTENSION` to not remove temporary files if needed
* Set chmod 755 on the plugin directory
* Some refactoring in the code
* Removing the `v` prefix in the version name

## v1.5.3 - 2021-05-05

Expand Down
21 changes: 7 additions & 14 deletions wfsOutputExtension/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
__email__ = '[email protected]'

import functools
import inspect
import time
import traceback

from contextlib import contextmanager
from pathlib import Path

from qgis.core import Qgis, QgsMessageLog

Expand All @@ -19,27 +17,24 @@ class Logger:

@staticmethod
def info(message: str):
QgsMessageLog.logMessage(PLUGIN + ' : ' + message, PLUGIN, Qgis.Info)
QgsMessageLog.logMessage(str(message), PLUGIN, Qgis.Info)

@staticmethod
def warning(message: str):
QgsMessageLog.logMessage(PLUGIN + ' : ' + message, PLUGIN, Qgis.Warning)
QgsMessageLog.logMessage(str(message), PLUGIN, Qgis.Warning)

@staticmethod
def critical(message: str):
QgsMessageLog.logMessage(PLUGIN + ' : ' + message, PLUGIN, Qgis.Critical)
QgsMessageLog.logMessage(str(message), PLUGIN, Qgis.Critical)

@staticmethod
def log_exception(e: BaseException):
""" Log a Python exception. """
QgsMessageLog.logMessage(
"Exception: {plugin}\n{e}\n{traceback}".format(
plugin=PLUGIN,
Logger.critical(
"Critical exception:\n{e}\n{traceback}".format(
e=e,
traceback=traceback.format_exc()
),
PLUGIN,
Qgis.Critical
)
)


Expand Down Expand Up @@ -69,9 +64,7 @@ def log_function_core(*args, **kwargs):
start = time.time()
value = func(*args, **kwargs)
end = time.time()
Logger.info(
"{}.{}.{} ran in {}s".format(
PLUGIN, Path(inspect.stack()[1].filename).stem, func.__name__, round(end - start, 2)))
Logger.info("{} ran in {}s".format(func.__name__, round(end - start, 2)))
return value

return log_function_core

0 comments on commit 2584efe

Please sign in to comment.