mirror of
https://github.com/chatmail/core.git
synced 2026-05-07 17:06:35 +03:00
docs: document how logs and error messages should be formatted
This commit is contained in:
@@ -76,6 +76,29 @@ If you have multiple changes in one PR, create multiple conventional commits, an
|
|||||||
[Conventional Commits]: https://www.conventionalcommits.org/
|
[Conventional Commits]: https://www.conventionalcommits.org/
|
||||||
[git-cliff]: https://git-cliff.org/
|
[git-cliff]: https://git-cliff.org/
|
||||||
|
|
||||||
|
### Errors
|
||||||
|
|
||||||
|
Delta Chat core mostly uses [`anyhow`](https://docs.rs/anyhow/) errors.
|
||||||
|
When using [`Context`](https://docs.rs/anyhow/latest/anyhow/trait.Context.html),
|
||||||
|
capitalize it but do not add a full stop as the contexts will be separated by `:`.
|
||||||
|
For example:
|
||||||
|
```
|
||||||
|
.with_context(|| format!("Unable to trash message {msg_id}"))
|
||||||
|
```
|
||||||
|
|
||||||
|
### Logging
|
||||||
|
|
||||||
|
For logging, use `info!`, `warn!` and `error!` macros.
|
||||||
|
Log messages should be capitalized and have a full stop in the end. For example:
|
||||||
|
```
|
||||||
|
info!(context, "Ignoring addition of {added_addr:?} to {chat_id}.");
|
||||||
|
```
|
||||||
|
|
||||||
|
Format anyhow errors with `{:#}` to print all the contexts like this:
|
||||||
|
```
|
||||||
|
error!(context, "Failed to set selfavatar timestamp: {err:#}.");
|
||||||
|
```
|
||||||
|
|
||||||
### Reviewing
|
### Reviewing
|
||||||
|
|
||||||
Once a PR has an approval and passes CI, it can be merged.
|
Once a PR has an approval and passes CI, it can be merged.
|
||||||
|
|||||||
Reference in New Issue
Block a user