locking this whenever you log could slow things down quite a bit. are you sure you need it? i mean - if errors go to stderr and data output goes to a file per client, you shouldn't need to lock to log.