In development I run my elixir apps inside a tmux session and occasionally I switch into copy mode to copy some output from the logs. Sometimes I leave tmux in copy mode which eventually causes my elixir application to “hang” (this is especially noticeable in Phoenix). I’m fairly sure that this is caused by the console logger’s
maximum events to buffer while waiting for a confirmation from the IO device (default: 32). Once the buffer is full, the backend will block until a confirmation is received.
from: Logger.Backends.Console — Logger v1.12.0-rc.0
A few times in the past it has taken me a long time to realize why my server is hanging. I’d prefer instead for my application to instead not block. I believe the purpose of
max_buffer is to prevent the logger from infinitely growing in memory usage. To solve this, it seems that there’s two options here, either let the terminal buffer everything (although perhaps something about the BEAM’s I/O makes this difficult) or just drop messages once the buffer overflows, adding a “Dropped log messages” message when it happens.
Am I understanding the reasoning for
max_buffer correctly? Has anyone written a console logger with that handles this case better?