Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove slog-async dependency #137

Merged
merged 1 commit into from
Jan 6, 2025

Conversation

karlding
Copy link
Contributor

@karlding karlding commented Jan 6, 2025

According to the slog-term docs:

> PlainSync Decorator implementation
>
> This implementation is exactly like PlainDecorator but it takes
> care of synchronizing writes to io.

Since we care about colouring, wrap a slog_term::TermDecorator in a std::sync::Mutex so that coloured output is still maintained.

This ensures that log messages will not be dropped when the logging rate exceeds the backend's ability to drain (as the previous slog-async backend could do). Previously when this occurred, the log output would show the following:

slog-async: logger dropped messages due to channel overflow

An alternative might be to keep the slog-async dependency but use slog_async::OverflowStrategy::Block to ensure that overflowing writes will block, rather than forcing each write through the mutex.

Fixes #131

According to the slog-term docs:

    > PlainSync Decorator implementation
    >
    > This implementation is exactly like PlainDecorator but it takes
    > care of synchronizing writes to io.

Since we care about colouring, wrap a slog_term::TermDecorator in a
std::sync::Mutex so that coloured output is still maintained.

This ensures that log messages will not be dropped when the logging
rate exceeds the backend's ability to drain (as the previous
slog-async backend could do). Previously when this occurred, the log
output would show the following:

    slog-async: logger dropped messages due to channel overflow

An alternative might be to keep the slog-async dependency but use
slog_async::OverflowStrategy::Block to ensure that overflowing writes
will block, rather than forcing each write through the mutex.

Fixes tummychow#131
@tummychow tummychow merged commit 2c2cf6b into tummychow:master Jan 6, 2025
3 checks passed
@karlding karlding deleted the remove_slog_async_dependency branch January 12, 2025 00:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ERRO slog-async: logger dropped messages due to channel overflow
2 participants