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

[RFC] Add logging support #28

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

korken89
Copy link
Collaborator

Summary

Add native logging support to RTFM using priority based buffers as in cortex-m-funnel.

Rendered

@korken89 korken89 requested review from japaric and a team as code owners December 28, 2019 15:33
# How We Teach This
[how-we-teach-this]: #how-we-teach-this

This should be added to the book as its own `Safe logging` chapter.
Copy link
Contributor

Choose a reason for hiding this comment

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

I would name the chapter 'non-blocking logging', 'real-time logging' or something like that. cortex-m-funnel is not the only memory safe global logger; the log and stlog crates also provide memory safe global loggers and would also be candidates for a 'Safe logging' chapter.


```rust
// Base size of 256 bytes, but the queue for priority 7 is of 1024 bytes
#[app(logger = [base = 256, 7 = 1024])]
Copy link
Contributor

Choose a reason for hiding this comment

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

The syntax of the #[app] arguments can be anything; the downside is that it never gets formatted by rustfmt. I personally would prefer not to enter so much data as an attribute arguments but can't think of a better syntax right now.

// ...
```

The final implementation of the logging is very simple. Simply, based on the analysis, fill out the [`cortex-m-funnel`] macro.
Copy link
Contributor

Choose a reason for hiding this comment

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

cortex-m-funnel only supports ufmt atm; do we want to wait for core::fmt support before implementing this?

# Drawbacks
[drawbacks]: #drawbacks

* Increase of complexity of RTFM, but I would argue that this is of much greater help than not to have it.
Copy link
Contributor

Choose a reason for hiding this comment

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

it also ties RTFM semver to cortex-m-funnel version so if we release a RTFM that uses cortex-m-funnel v0.1 it probably won't work with the log! macro of cortex-m-funnel v0.2. I'm unsure about what kind of error you would get in that case; perhaps a linker error or perhaps all data that goes through the v0.2 of log! would be silently loss

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.

2 participants