capture, capture_to_file, capture_and_serve) cover most use cases, but sometimes you need finer control — for example, interleaving multiple traced phases, conditionally saving only on failure, or loading a previously recorded session. The session management functions let you do all of this explicitly.
When to use manual management
Use the manual API when you need to:- Run instrumented code across multiple separate call sites and collect it all into one session
- Conditionally persist a session (e.g. only on error)
- Load a saved
.jsonfile or a directory of session files for programmatic inspection - Combine session collection with custom error handling or structured logging
dbgflow::init_session
#[trace], #[ui_debug]) called after this point record their events into this new session.
Parameters
Returns nothing.
Calling
init_session again at any point discards the previous session and starts a new one. If you need to preserve the existing session, call save_current_session first.dbgflow::save_current_session
save_current_session again to overwrite or save to a different path.
Parameters
Returns
std::io::Result<()> — Ok(()) on success, or an Err if the file cannot be written.
dbgflow::serve_current_session
Returns
std::io::Result<()> — Ok(()) when the server shuts down, or an Err if it fails to start.
dbgflow::load_saved_session
Session value. The path can point to either a single .json file or a directory containing multiple .json files.
Parameters
Returns
std::io::Result<Session> — the loaded (or merged) session on success.
Loading a single file
Loading a directory
When the path is a directory,load_saved_session reads every .json file in it, sorts them by filename, and merges them into a single Session. Each individual session becomes a separate pipeline in the merged result.