Commit 195b352c authored by Romain Loth's avatar Romain Loth

better logging

parent f73da214
......@@ -163,7 +163,7 @@ def get_field_aggs(a_field, hapax_threshold=int(REALCONFIG['HAPAX_THRESHOLD'])):
""" % {'col': sql_col, 'filter': where_clause}
mlog("DEBUG", "get_field_aggs STATEMENT:\n-- SQL\n%s\n-- /SQL" % stmt)
mlog("DEBUGSQL", "get_field_aggs STATEMENT:\n-- SQL\n%s\n-- /SQL" % stmt)
# do it
n_rows = db_c.execute(stmt)
......@@ -236,7 +236,7 @@ def get_full_scholar(uid):
-- two step JOIN for keywords
LEFT JOIN sch_kw
ON sch_n_aff.doors_uid = sch_kw.uid
JOIN keywords
LEFT JOIN keywords
ON sch_kw.kwid = keywords.kwid
GROUP BY doors_uid
......@@ -250,15 +250,15 @@ def get_full_scholar(uid):
GROUP BY doors_uid
""" % str(uid)
mlog("DEBUG", "get_full_scholar STATEMENT:\n-- SQL\n%s\n-- /SQL" % one_usr_stmt)
mlog("DEBUGSQL", "DB get_full_scholar STATEMENT:\n-- SQL\n%s\n-- /SQL" % one_usr_stmt)
n_rows = db_c.execute(one_usr_stmt)
if n_rows > 1:
raise IndexError("one_usr_stmt returned %i rows instead of 1 for user %s" % (n_rows, uid))
raise IndexError("DB one_usr_stmt returned %i rows instead of 1 for user %s" % (n_rows, uid))
elif n_rows == 0:
mlog("WARNING", "get_full_scholar attempt to read non-existing user %s" % uid)
mlog("WARNING", "DB get_full_scholar attempt got no rows for: %s" % uid)
db.close()
return None
......@@ -365,12 +365,15 @@ def save_scholar(uid, date, safe_recs, reg_db, uactive=True, update_flag=False):
quotedstrval = ""
if colname != 'pic_file':
quotedstrval = "'"+str(val)+"'"
mlog("DEBUG", "DB saving" + quotedstrval)
else:
mlog("DEBUG", "picture file is len0?", len(val) == 0 )
mlog("DEBUG", "DB picture file is len0?", len(val) == 0 )
# str(val) for a bin is already quoted but has the 'b' prefix
quotedstrval = '_binary'+str(val)[1:] # TODO check if \x needs to land in target sql ?
mlog("DEBUG", "added pic blob: " + quotedstrval[:25] + '...' + quotedstrval[-10:])
mlog("DEBUG", "DB added pic blob: " + quotedstrval[:25] + '...' + quotedstrval[-10:])
# anyways
db_tgtcols.append(colname)
......
......@@ -266,6 +266,8 @@ def login():
if uid:
login_ok = login_user(User(uid))
mlog('INFO', 'login of %s was %s' % (uid, str(login_ok)))
# TODO check cookie
# login_ok = login_user(User(uid), remember=True)
# -------------
......@@ -339,12 +341,14 @@ def profile():
if current_user.empty:
mlog("INFO", "PROFILE: empty current_user %s" % current_user.uid)
else:
mlog("DEBUG", "PROFILE: current_user %s\n -" % current_user.uid
+ '\n - '.join([current_user.info['email'],
mlog("INFO", "PROFILE: current_user %s" % current_user.uid)
mlog("DEBUG", "PROFILE: current_user details: \n - %s" % (
'\n - '.join([current_user.info['email'],
current_user.info['initials'],
str(current_user.info['keywords']),
current_user.info['country']]
)
)
)
# debug session cookies
......@@ -361,6 +365,7 @@ def profile():
# and {{current_user.json_info}}
)
elif request.method == 'POST':
mlog("DEBUG", "saving profile with request.form=", request.form)
try:
save_form(
request.form,
......
......@@ -191,7 +191,7 @@ def mlog(loglvl, *args):
config['LOG_TEE'] (bool) decides if logs also go to STDOUT
"""
levels = {"DEBUG":0, "INFO":1, "WARNING":2, "ERROR":3}
levels = {"DEBUGSQL":-1, "DEBUG":0, "INFO":1, "WARNING":2, "ERROR":3}
if 'LOG_FILE' in REALCONFIG:
logfile = open(REALCONFIG["LOG_FILE"], "a") # a <=> append
......
......@@ -70,6 +70,9 @@ def doors_login(email, password, config):
doors_base_url = 'http://'+config['DOORS_HOST']+':'+config['DOORS_PORT']
doors_response = post(doors_base_url+'/api/user', data=dumps({'login':email, 'password':password}))
print("doors_response",doors_response)
mlog("INFO", "doors_response",doors_response)
if doors_response.ok:
login_info = loads(doors_response.content.decode())
......
......@@ -197,14 +197,19 @@ $(document).ready(function() {
return "" + ui.item.firstname + " " + ui.item.lastname;
}
});
// main form collect function
collectFilters = function(cb) {
var collect, query;
collect = function(k) {
var t;
t = [];
log("collecting .filter" + k);
log("collecting .filter:" + k);
$(".filter" + k).each(function(i, e) {
var value;
console.log('collecting (filter '+k+') from elt:' + e)
value = $(e).val();
if (value != null) {
log("got: " + value);
......@@ -249,6 +254,10 @@ $(document).ready(function() {
console.log("calling callback with encoded query:", query)
return cb(query);
};
// refine filters => tinawebjs graphexplorer
$("#generate").click(function() {
hide(".hero-unit");
return $("#welcome").fadeOut("slow", function() {
......
......@@ -68,7 +68,7 @@
<p class="pull-up-right">
<a target="_blank" href="/explorerjs.html?type=%22filter%22&nodeidparam=%22%257B%257D%22">
<span class="glyphicon glyphicon-new-window"></span>
Open in another window
Open in another tab
</a>
</p>
</div>
......@@ -112,7 +112,7 @@
<p class="pull-up-right">
<a target="_blank" href="/services/user/{% if current_user.info %}profile{% else %}register{% endif %}">
<span class="glyphicon glyphicon-new-window"></span>
Open in another window
Open in another tab
</a>
</p>
</div>
......@@ -158,7 +158,7 @@
<p class="pull-up-right">
<a target="_blank" href="/index.html">
<span class="glyphicon glyphicon-new-window"></span>
Open in another window
Open in another tab
</a>
</p>
</div>
......@@ -197,7 +197,7 @@
<p class="pull-up-right">
<a target="_blank" href="/print_directory.php?query=%7B%7D">
<span class="glyphicon glyphicon-new-window"></span>
Open in another window
Open in another tab
</a>
</p>
</div>
......@@ -242,7 +242,7 @@
<p class="pull-up-right">
<a target="_blank" href="/explorerjs.html?type=%22filter%22&nodeidparam=%22%257B%257D%22">
<span class="glyphicon glyphicon-new-window"></span>
Open in another window
Open in another tab
</a>
</p>
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment