forked from anitagraser/TimeManager
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtmlogging.py
More file actions
51 lines (34 loc) · 1.16 KB
/
Copy pathtmlogging.py
File metadata and controls
51 lines (34 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/python
# -*- coding: UTF-8 -*-
"""
Logging utilities to log messages in QGIS with
a separate tab just for Time Manager
"""
__author__ = 'carolinux'
from qgis._core import QgsMessageLog
import conf
def info(msg): # pragma: no cover
QgsMessageLog.logMessage(str(msg), conf.LOG_TAG, QgsMessageLog.INFO)
def warn(msg): # pragma: no cover
QgsMessageLog.logMessage(str(msg), conf.LOG_TAG)
def error(msg): # pragma: no cover
QgsMessageLog.logMessage(str(msg), conf.LOG_TAG, QgsMessageLog.CRITICAL)
def log_exceptions(func): # pragma: no cover
def log_after(*args, **kwargs):
try:
return func(*args, **kwargs)
except Exception, e:
error("Exception in function {}:{}".format(str(func), str(e)))
return
return log_after
def debug_on_exceptions(func): # pragma: no cover
""" Only used for debugging"""
def debug_after(*args, **kwargs):
try:
return func(*args, **kwargs)
except Exception, e:
from PyQt4.QtCore import pyqtRemoveInputHook
pyqtRemoveInputHook()
import pdb
pdb.set_trace()
return debug_after