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

defmt global logger with rtt-target #54

Open
Gibbz opened this issue Nov 8, 2024 · 1 comment
Open

defmt global logger with rtt-target #54

Gibbz opened this issue Nov 8, 2024 · 1 comment

Comments

@Gibbz
Copy link

Gibbz commented Nov 8, 2024

I want to setup a global logger so I can intercept the log messages for an extra output over bluetooth. But I dont know how to point my functions to the rtt-target functions....
https://defmt.ferrous-systems.com/global-logger

pub fn set_defmt_channel(channel: UpChannel) {
   rtt_target::set_defmt_channel(...) // this on is possible
}

unsafe impl defmt::Logger for Logger {
    fn acquire() {
        rtt_target::defmt::acquire() // not accessible
    }
    unsafe fn flush() {
         rtt_target::defmt::flush() // not accessible
    }
    unsafe fn release() {
         rtt_target::defmt::release() // not accessible
    }
    unsafe fn write(bytes: &[u8]) {
         rtt_target::defmt::write(...) // not accessible
    }
}
@bugadani
Copy link
Contributor

To do something like this, you'll need to keep the "defmt" feature disabled, copy the contents of defmt.rs and modify that for your needs. The "defmt" feature automatically registers a global logger, so you can't make another beside it.

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

No branches or pull requests

2 participants