-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgnucash_log.py
More file actions
59 lines (45 loc) · 2.2 KB
/
gnucash_log.py
File metadata and controls
59 lines (45 loc) · 2.2 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
52
53
54
55
56
57
58
59
from __future__ import print_function
import sys
import pdb
# emulation of the g_log functions in gnucash
# whats missing is calling function name for the moment
import glib_glog
#pdb.set_trace()
# oh well thats not going to work - we need to pass log_module
def FATAL (log_module, msg):
glib_glog.libglib.g_log(log_module.encode('utf-8'), glib_glog.GLogLevelFlags.G_LOG_LEVEL_ERROR, msg.encode('utf-8'))
def PERR (log_module, msg):
glib_glog.libglib.g_log(log_module.encode('utf-8'), glib_glog.GLogLevelFlags.G_LOG_LEVEL_CRITICAL, msg.encode('utf-8'))
def PWARN (log_module, msg):
glib_glog.libglib.g_log(log_module.encode('utf-8'), glib_glog.GLogLevelFlags.G_LOG_LEVEL_WARNING, msg.encode('utf-8'))
def PINFO (log_module, msg):
glib_glog.libglib.g_log(log_module.encode('utf-8'), glib_glog.GLogLevelFlags.G_LOG_LEVEL_INFO, msg.encode('utf-8'))
def PDEBUG (log_module, msg):
glib_glog.libglib.g_log(log_module.encode('utf-8'), glib_glog.GLogLevelFlags.G_LOG_LEVEL_DEBUG, msg.encode('utf-8'))
def ENTER (log_module, msg):
msg = "[enter : "+msg+"]"
glib_glog.libglib.g_log(log_module.encode('utf-8'), glib_glog.GLogLevelFlags.G_LOG_LEVEL_DEBUG, msg.encode('utf-8'))
def LEAVE (log_module, msg):
msg = "[leave : "+msg+"]"
glib_glog.libglib.g_log(log_module.encode('utf-8'), glib_glog.GLogLevelFlags.G_LOG_LEVEL_DEBUG, msg.encode('utf-8'))
# create a gnc_error message function to emulate the scheme error functions
def gnc_msg (msg):
glib_glog.libglib.g_log(b"gnc.python", glib_glog.GLogLevelFlags.G_LOG_LEVEL_MESSAGE, msg.encode('utf-8'))
def gnc_warn (msg):
glib_glog.libglib.g_log(b"gnc.python", glib_glog.GLogLevelFlags.G_LOG_LEVEL_WARNING, msg.encode('utf-8'))
def gnc_error (msg):
glib_glog.libglib.g_log(b"gnc.python", glib_glog.GLogLevelFlags.G_LOG_LEVEL_CRITICAL, msg.encode('utf-8'))
def gnc_debug (msg):
glib_glog.libglib.g_log(b"gnc.python", glib_glog.GLogLevelFlags.G_LOG_LEVEL_DEBUG, msg.encode('utf-8'))
# some junky print functions for debugging
# so can turn them off easily
debug = False
#debug = True
def dbglog(*args):
#pdb.set_trace()
if debug:
print(*args)
def dbglog_err(*args):
#pdb.set_trace()
if debug:
print(*args,file=sys.stderr)