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'])): ...@@ -163,7 +163,7 @@ def get_field_aggs(a_field, hapax_threshold=int(REALCONFIG['HAPAX_THRESHOLD'])):
""" % {'col': sql_col, 'filter': where_clause} """ % {'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 # do it
n_rows = db_c.execute(stmt) n_rows = db_c.execute(stmt)
...@@ -236,7 +236,7 @@ def get_full_scholar(uid): ...@@ -236,7 +236,7 @@ def get_full_scholar(uid):
-- two step JOIN for keywords -- two step JOIN for keywords
LEFT JOIN sch_kw LEFT JOIN sch_kw
ON sch_n_aff.doors_uid = sch_kw.uid ON sch_n_aff.doors_uid = sch_kw.uid
JOIN keywords LEFT JOIN keywords
ON sch_kw.kwid = keywords.kwid ON sch_kw.kwid = keywords.kwid
GROUP BY doors_uid GROUP BY doors_uid
...@@ -250,15 +250,15 @@ def get_full_scholar(uid): ...@@ -250,15 +250,15 @@ def get_full_scholar(uid):
GROUP BY doors_uid GROUP BY doors_uid
""" % str(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) n_rows = db_c.execute(one_usr_stmt)
if n_rows > 1: 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: 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() db.close()
return None return None
...@@ -365,12 +365,15 @@ def save_scholar(uid, date, safe_recs, reg_db, uactive=True, update_flag=False): ...@@ -365,12 +365,15 @@ def save_scholar(uid, date, safe_recs, reg_db, uactive=True, update_flag=False):
quotedstrval = "" quotedstrval = ""
if colname != 'pic_file': if colname != 'pic_file':
quotedstrval = "'"+str(val)+"'" quotedstrval = "'"+str(val)+"'"
mlog("DEBUG", "DB saving" + quotedstrval)
else: 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 # 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 ? 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 # anyways
db_tgtcols.append(colname) db_tgtcols.append(colname)
......
...@@ -266,6 +266,8 @@ def login(): ...@@ -266,6 +266,8 @@ def login():
if uid: if uid:
login_ok = login_user(User(uid)) login_ok = login_user(User(uid))
mlog('INFO', 'login of %s was %s' % (uid, str(login_ok)))
# TODO check cookie # TODO check cookie
# login_ok = login_user(User(uid), remember=True) # login_ok = login_user(User(uid), remember=True)
# ------------- # -------------
...@@ -339,12 +341,14 @@ def profile(): ...@@ -339,12 +341,14 @@ def profile():
if current_user.empty: if current_user.empty:
mlog("INFO", "PROFILE: empty current_user %s" % current_user.uid) mlog("INFO", "PROFILE: empty current_user %s" % current_user.uid)
else: else:
mlog("DEBUG", "PROFILE: current_user %s\n -" % current_user.uid mlog("INFO", "PROFILE: current_user %s" % current_user.uid)
+ '\n - '.join([current_user.info['email'], mlog("DEBUG", "PROFILE: current_user details: \n - %s" % (
'\n - '.join([current_user.info['email'],
current_user.info['initials'], current_user.info['initials'],
str(current_user.info['keywords']), str(current_user.info['keywords']),
current_user.info['country']] current_user.info['country']]
) )
)
) )
# debug session cookies # debug session cookies
...@@ -361,6 +365,7 @@ def profile(): ...@@ -361,6 +365,7 @@ def profile():
# and {{current_user.json_info}} # and {{current_user.json_info}}
) )
elif request.method == 'POST': elif request.method == 'POST':
mlog("DEBUG", "saving profile with request.form=", request.form)
try: try:
save_form( save_form(
request.form, request.form,
......
...@@ -191,7 +191,7 @@ def mlog(loglvl, *args): ...@@ -191,7 +191,7 @@ def mlog(loglvl, *args):
config['LOG_TEE'] (bool) decides if logs also go to STDOUT 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: if 'LOG_FILE' in REALCONFIG:
logfile = open(REALCONFIG["LOG_FILE"], "a") # a <=> append logfile = open(REALCONFIG["LOG_FILE"], "a") # a <=> append
......
...@@ -70,6 +70,9 @@ def doors_login(email, password, config): ...@@ -70,6 +70,9 @@ def doors_login(email, password, config):
doors_base_url = 'http://'+config['DOORS_HOST']+':'+config['DOORS_PORT'] doors_base_url = 'http://'+config['DOORS_HOST']+':'+config['DOORS_PORT']
doors_response = post(doors_base_url+'/api/user', data=dumps({'login':email, 'password':password})) 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: if doors_response.ok:
login_info = loads(doors_response.content.decode()) login_info = loads(doors_response.content.decode())
......
...@@ -197,14 +197,19 @@ $(document).ready(function() { ...@@ -197,14 +197,19 @@ $(document).ready(function() {
return "" + ui.item.firstname + " " + ui.item.lastname; return "" + ui.item.firstname + " " + ui.item.lastname;
} }
}); });
// main form collect function
collectFilters = function(cb) { collectFilters = function(cb) {
var collect, query; var collect, query;
collect = function(k) { collect = function(k) {
var t; var t;
t = []; t = [];
log("collecting .filter" + k); log("collecting .filter:" + k);
$(".filter" + k).each(function(i, e) { $(".filter" + k).each(function(i, e) {
var value; var value;
console.log('collecting (filter '+k+') from elt:' + e)
value = $(e).val(); value = $(e).val();
if (value != null) { if (value != null) {
log("got: " + value); log("got: " + value);
...@@ -249,6 +254,10 @@ $(document).ready(function() { ...@@ -249,6 +254,10 @@ $(document).ready(function() {
console.log("calling callback with encoded query:", query) console.log("calling callback with encoded query:", query)
return cb(query); return cb(query);
}; };
// refine filters => tinawebjs graphexplorer
$("#generate").click(function() { $("#generate").click(function() {
hide(".hero-unit"); hide(".hero-unit");
return $("#welcome").fadeOut("slow", function() { return $("#welcome").fadeOut("slow", function() {
......
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
<p class="pull-up-right"> <p class="pull-up-right">
<a target="_blank" href="/explorerjs.html?type=%22filter%22&nodeidparam=%22%257B%257D%22"> <a target="_blank" href="/explorerjs.html?type=%22filter%22&nodeidparam=%22%257B%257D%22">
<span class="glyphicon glyphicon-new-window"></span> <span class="glyphicon glyphicon-new-window"></span>
Open in another window Open in another tab
</a> </a>
</p> </p>
</div> </div>
...@@ -112,7 +112,7 @@ ...@@ -112,7 +112,7 @@
<p class="pull-up-right"> <p class="pull-up-right">
<a target="_blank" href="/services/user/{% if current_user.info %}profile{% else %}register{% endif %}"> <a target="_blank" href="/services/user/{% if current_user.info %}profile{% else %}register{% endif %}">
<span class="glyphicon glyphicon-new-window"></span> <span class="glyphicon glyphicon-new-window"></span>
Open in another window Open in another tab
</a> </a>
</p> </p>
</div> </div>
...@@ -158,7 +158,7 @@ ...@@ -158,7 +158,7 @@
<p class="pull-up-right"> <p class="pull-up-right">
<a target="_blank" href="/index.html"> <a target="_blank" href="/index.html">
<span class="glyphicon glyphicon-new-window"></span> <span class="glyphicon glyphicon-new-window"></span>
Open in another window Open in another tab
</a> </a>
</p> </p>
</div> </div>
...@@ -197,7 +197,7 @@ ...@@ -197,7 +197,7 @@
<p class="pull-up-right"> <p class="pull-up-right">
<a target="_blank" href="/print_directory.php?query=%7B%7D"> <a target="_blank" href="/print_directory.php?query=%7B%7D">
<span class="glyphicon glyphicon-new-window"></span> <span class="glyphicon glyphicon-new-window"></span>
Open in another window Open in another tab
</a> </a>
</p> </p>
</div> </div>
...@@ -242,7 +242,7 @@ ...@@ -242,7 +242,7 @@
<p class="pull-up-right"> <p class="pull-up-right">
<a target="_blank" href="/explorerjs.html?type=%22filter%22&nodeidparam=%22%257B%257D%22"> <a target="_blank" href="/explorerjs.html?type=%22filter%22&nodeidparam=%22%257B%257D%22">
<span class="glyphicon glyphicon-new-window"></span> <span class="glyphicon glyphicon-new-window"></span>
Open in another window Open in another tab
</a> </a>
</p> </p>
</div> </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