moby / vpnkit

A toolkit for embedding VPN capabilities in your application
Apache License 2.0
1.1k stars 187 forks source link

logging: ensure we don't block the stack #566

Closed djs55 closed 2 years ago

djs55 commented 2 years ago

Previously the logging is a plain write to "stderr" which can block the main Lwt/Uwt thread, blocking the stack.

Instead, log to a Buffer, and drain it in a background Thread. If the buffer is full, drop messages and increment a dropped bytes counter. Always log if we drop messages to help debugging.

Also some minor improvements: