Use sqlite last_insert_rowid for logs