Skip to content

Conversation

@Simon-Laux
Copy link
Contributor

The events are needed when you are not using chatmail core from rust, if
you use chatmail core from your rust bot or from tauri, then you likely
already use the rust logging/tracing ecosystem. So it makes sense to use
it instead of listening to the events and logging them yourself.

This pr fixes a few cases where the event was direclty emitted instead
of using the macro and thus was not also automatically logged via
tracing.

is also logged by tracing

The events are needed when you are not using chatmail core from rust, if
you use chatmail core from your rust bot or from tauri, then you likely
already use the rust logging/tracing ecosystem. So it makes sense to use
it instead of listening to the events and logging them yourself.

This pr fixes a few cases where the event was direclty emitted instead
of using the macro and thus was not also automatically logged via
tracing.
@Simon-Laux Simon-Laux marked this pull request as ready for review November 16, 2025 22:53
"Starting background fetch for {n_accounts} accounts."
)),
});
::tracing::event!(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add some function to Events that also does this, to avoid code duplication?

Copy link
Contributor Author

@Simon-Laux Simon-Laux Nov 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

normally it is inside of the logging macros, but the problem here is that we would need to either adapt the macro or duplicate and modify it to allow calling it without a structure/type with a .get_id(&self) method.
I don't felt confident doing either of those bigger changes/decisions.
The methods here are special, because they don't want to capture self.

Another idea could be a dummy struct that would provide a .get_id(&self) which just returns 0, but that feels like a hack to me.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need a trait for ctx passed into logging macros. Currently Context is actually an account and also acts as a logging context, we should split these concepts. This is not a subject for this PR of course. Another benefit of such a logging context may be storing some logging prefix or activity id which is logged as a log line prefix. This way we can make logs structured which may be useful for multi-transport, otherwise it may not be clear in the context of which transport an event occurs.

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.

3 participants