defmt VS tracing

Compare defmt vs tracing and see what are their differences.

Our great sponsors
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • SaaSHub - Software Alternatives and Reviews
defmt tracing
17 52
713 4,939
5.0% 3.3%
8.8 7.8
8 days ago 6 days ago
Rust Rust
Apache License 2.0 MIT License
The number of mentions indicates the total number of mentions that we've tracked plus the number of user suggested alternatives.
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.

defmt

Posts with mentions or reviews of defmt. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2023-07-31.
  • I built a column staggered keyboard with firmware written in Rust!
    5 projects | /r/rust | 31 Jul 2023
    As someone who had only done embedded programming in the Arduino IDE, utilizing the defmt crate for logging with OpenOCD and GDB was an amazing experience. Although I still had no idea on to implement USB-HID for actually sending the key reports, until I discovered the usbd-human-interface-device crate and everything became so much easier. I just needed to create an iterator over Keyboard events and the crate would handle the rest as an added benefit the crate also supports multiple devices, so adding mouse support was as easy as creating a separate iterator over WheelMouseReport.
  • Testing a no_std crate with QEMU and defmt-test?
    1 project | /r/rust | 16 Jun 2023
    I think I want to use the QEMU emulator (as suggested in the Embedded Rust Book) and tests created with defmt-test. But I can't figure out how to get them to work together.
  • Are there any `no_std` logging or printing libraries (for Wasm targets, or even embedded devices)
    1 project | /r/rust | 12 Apr 2023
    On embeded defmt is often used https://github.com/knurling-rs/defmt
  • Debugging and profiling embedded applications.
    8 projects | /r/rust | 30 Mar 2023
    defmt is a great framework for general logging.
  • Print From a Multi-Platform no_std Embedded Library
    1 project | /r/rust | 18 Jan 2023
  • Native Reflection in Rust
    2 projects | news.ycombinator.com | 15 Dec 2022
    Great writeup! The defmt logging crate uses a linker script to extract debug symbols so that you get nicely formatted stack traces on embedded systems. It works on linux, macos and windows. I wonder if the same technique can be applied to this project. It needs a runner though so may not be the right approach.

    https://github.com/knurling-rs/defmt

  • Smallest logging implementation?
    2 projects | /r/rust | 4 Nov 2022
  • From arduino to rust via avr-hal
    2 projects | /r/rust | 16 Oct 2022
    Just played with embedded stuff today. defmt can be used for logging instead of println since there's not really a stdout when running on bare metal.
  • Are costly debuggers from vendors necessary?
    1 project | /r/embedded | 22 Jun 2022
    yYeah. For example, instead of printf("Variable X = %d, y=%f", x, y), where the micro then formats the string and pushes it out a serial port, blocking until its sent, I can write LOG("Variable X = %d, Y=%f, x, y), and what actually happens is a unique pointer to the string, and a tagged raw int and float get pushed onto a buffer, which takes about 15 instructions and takes up 16 bytes in the buffer. The buffer is then asynchronously sent out over the serial port, and the PC knows how to map the string ID to the actual string (this can by dynamically fetched from the micro or stored like debug info if there's not enough flash for the strings), and applies the formatting. There's an added bonus that it's super easy to take any variable which is logged and plot it live over time. There's also stuff like if the system crashes and the watchdog resets it, the buffer can be read out from memory to catch anything which wasn't sent out yet. It's a bit more of a complex system to set up but it really makes printf feel like the stone age when you get to using it. For an example of a similar system in rust, https://github.com/knurling-rs/defmt is implementing the same ideas (I don't know of any publicly available equivalent in C or C++, but you can implement it the same, though C++ is easier and it helps to know your way around a linker script to make something properly ergonomic).
  • Creating formatted strings with no_std on embedded
    1 project | /r/rust | 1 May 2022
    If the build constraints are amenable for your project, you might also enjoy knurling-rs' defmt logging framework.

tracing

Posts with mentions or reviews of tracing. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2023-10-31.
  • Decrusting the tracing crate [video] by Jon Gjengset
    1 project | news.ycombinator.com | 10 Feb 2024
    The video description is as follows:

    In this stream, we peel back the crust on the tracing crate — https://github.com/tokio-rs/tracing/ — and explore its interface, structure, and mechanisms. We talk about spans, events, their attributes and fields, and how to think about them in async code. We also dig into what subscribers are, how they pick up events, and how you can construct your own subscribers through the layer abstraction. For more details about tracing, see https://docs.rs/tracing/latest/tracing/.

  • Vendor lock-in is in the small details
    7 projects | news.ycombinator.com | 31 Oct 2023
    > What's been your biggest issues around ergonomics/amenities for OpenTelemetry?

    I can't speak generally, but in the Rust ecosystem the various crates don't play well together. Here's one example: <https://github.com/tokio-rs/tracing/issues/2648> There are four crates involved (tracing-attributes, tracing-opentelemetry, opentelemetry, and opentelemetry-datadog) and none of them fit properly into any of the others.

  • Grimoire - A recipe management application.
    7 projects | /r/rust | 5 Oct 2023
    The tracing (logging) mechanism in an asynchronous codebase (tracing).
  • How easy is it to swap out your async runtime?
    2 projects | /r/rust | 10 Jul 2023
    Tracing is Tokio's alternative for async code.
  • Hey Rustaceans! Got a question? Ask here (27/2023)!
    9 projects | /r/rust | 3 Jul 2023
    At a technical level, in Rust, both [tracing]https://crates.io/crates/tracing) and log are entire ecosystems (though for the latter at least there's also third party logging frameworks), and there's at least a bridge from log to tracing.
  • How can I write a tracing subscriber that saves to a database?
    1 project | /r/rust | 3 Jul 2023
    I am using https://github.com/tokio-rs/tracing for logging purposes in my application. I would like to develop a feature wherein logs should be saved to a database table (via sea-orm). Something similar is this, but it does not solve my needs fully.
  • A locking war story
    2 projects | /r/rust | 1 Jun 2023
    I've used the tracing infrastructure with tracing_flame to profile some hot paths in async code: https://github.com/tokio-rs/tracing/tree/master/tracing-flame
  • I was wrong about rust
    4 projects | /r/rust | 20 May 2023
    Oh nice! IIRC when I checked, it was the Unicode tables that smashed the code size. I recently hit the same issue with the tracing crate, where a crate feature (for env var filtering) pulled in regex and my binary was suddenly 1MB bigger.
  • Debugging and profiling embedded applications.
    8 projects | /r/rust | 30 Mar 2023
    I know about tools such as tracing, jaeger or tracy. While having a complete tracing could be a potential solution, these tools don't work with no_std.
  • Custom Axum Logging for Routes?
    2 projects | /r/rust | 17 Mar 2023
    tracing by itself only outputs log data, you need to consume them in a subscriber, the tracing-subscriber crate exists for this. (example)

What are some alternatives?

When comparing defmt and tracing you can also consider the following projects:

cargo-embed - a cargo extension for working with microcontrollers

log4rs - A highly configurable logging framework for Rust

probe-run - Run embedded programs just like native ones

slog - Structured, contextual, extensible, composable logging for Rust

trice - 🟢 super fast 🚀 and tiny 🐥 embedded device 𝘾 printf-like trace ✍ code, works also inside ⚡ interrupts ⚡ and real-time PC 💻 logging (trace ID visualization 👀)

env_logger - A logging implementation for `log` which is configured via an environment variable.

flip-link - Adds zero-cost stack overflow protection to your embedded programs

log - Logging implementation for Rust

nanoprintf - The smallest public printf implementation for its feature set.

opentelemetry-rust - The Rust OpenTelemetry implementation

itm - ARMv7-M ITM packet protocol decoder library crate and CLI tool.

vector - A high-performance observability data pipeline.