ws_log() reimplementation for newline character appending

Please review carefully.
This can and should be moved to line 95.