-
Notifications
You must be signed in to change notification settings - Fork 1
/
logger.py
31 lines (25 loc) · 883 Bytes
/
logger.py
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
from datetime import datetime
import thread
from webscard.models import operation
from webscard.utils import dbsession
def doit(input, output):
try:
function, hContext, inparams = input
hresult, outparams = output
opclass = operation.getclassfor(function)
op = opclass(function, hContext, **inparams)
op.performed(hresult, **outparams)
dbsession.add(op)
finally:
dbsession.flush()
dbsession.remove()
def loginput(request, hContext, **params):
if 'time' not in params:
params['time'] = datetime.now()
# get the caller name from the stack
function = request.endpoint
return (function, hContext.uid, params)
def logoutput(inparams, hresult, **params):
if 'time' not in params:
params['time'] = datetime.now()
thread.start_new(doit, (inparams, (hresult, params),))