First stab at making sql logging threadsafe