""" User activity logging functions """

__version__ = "$Revision: 1.10 $"
# $Source: /home/vladap/src/mysqlUserFolder/RCS/log.py,v $
#
# $Author: vladap $
# $Date: 2004/05/15 18:25:16 $

import cfg

# --------------------------------------------------------------------- */
# Session logging


def session_log_begin (db, realm, session):
	db.log_sql_simple (realm, session.getDBId (), 'Begin') 
		
def session_log_end (db, realm, session):
	db.log_sql_simple (realm, session.getDBId (), 'End')

def session_log_access (db, realm, session, path, param_str, obj, raddr):
	
	try: meta_type = getattr (obj, 'meta_type')
	except: meta_type = ''
	
	try: size = obj.get_size ()
	except: size = 0
	
	if type (size) != type (0): size = 0
		
	db.log_sql (realm, session.getDBId (), 'Access', path, param_str, 
													meta_type, size, raddr)
	
def session_log_login (db, realm, session, username, raddr):
	db.log_sql (realm, session.getDBId (), 'Login', username, '', '', 0, raddr)
	
def session_log_login_failed (db, realm, session, username, passw, raddr):
	if session:
		sid = session.getDBId ()
	else:
		sid = cfg.VDB_INVALID_ID
	
	db.log_sql (realm, sid, 'FLogin', username, passw, '', 0, raddr)


