Use with lock instead of lock.acquire
backported wiredlogging from webif branch
merge locking and logging branches