Skip to content

Commit

Permalink
Add small example of tracing logging
Browse files Browse the repository at this point in the history
  • Loading branch information
sbarral committed Sep 13, 2024
1 parent 7487a26 commit 1dfb79f
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions asynchronix/src/tracing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,23 @@
//! tracing_subscriber::fmt::init();
//! ```
//!
//! Logging from a model is then a simple matter of using the `tracing` macros,
//! for instance:
//!
//! ```
//! use tracing::warn;
//!
//! pub struct MyModel { /* ... */ }
//!
//! impl MyModel {
//! pub fn some_input_port(&mut self, _some_parameter: i32) {
//! // ...
//! warn!("something happened inside the simulation");
//! // ...
//! }
//! }
//! ```
//!
//! However, this will stamp events with the system time rather than the
//! simulation time. To use simulation time instead, a dedicated timer can be
//! configured:
Expand All @@ -44,8 +61,8 @@
//! .init();
//! ```
//!
//! Note that this timer will automatically revert to system time stamping for
//! tracing events generated outside of simulation models, e.g.:
//! This timer will automatically revert to system time stamping for tracing
//! events generated outside of simulation models, e.g.:
//!
//! ```text
//! [2001-02-03 04:05:06.789012345] WARN model{name="my_model"}: my_simulation: something happened inside the simulation
Expand Down

0 comments on commit 1dfb79f

Please sign in to comment.