log refactor, add socket handler