SQL log, SQL function not tested