Skip to content

Comments

Remove slog-async dependency#137

Merged
tummychow merged 1 commit intotummychow:masterfrom
karlding:remove_slog_async_dependency
Jan 6, 2025
Merged

Remove slog-async dependency#137
tummychow merged 1 commit intotummychow:masterfrom
karlding:remove_slog_async_dependency

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