1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
use process_log_for_url;
use crate;
use ;
use Path;
/// Showcase the log data by sending it to the showcase server
///
/// This function processes a log file and opens a browser window to visualize
/// the thread-lock relationships recorded in the log. The visualization is
/// hosted on a web server and can help identify the patterns that led to a deadlock.
///
/// # Arguments
/// * `log_path` - Path to the log file.
///
/// # Returns
/// A Result that is Ok if the showcase succeeded, or an error if it failed.
///
/// # Errors
/// Returns an error if:
/// - Failed to read the log file
/// - Failed to process the log file
/// - Failed to open the browser
///
/// # Example
///
/// ```no_run
/// use deloxide::showcase;
/// use std::path::Path;
///
/// // After a deadlock has been detected and logged
/// let log_path = Path::new("deadlock_log.json");
/// showcase(log_path).expect("Failed to showcase deadlock visualization");
/// ```
/// Showcase the current active log file
///
/// This is a convenience function that showcases the log file that was specified
/// in the Deloxide::with_log() initialization. It's useful when you don't want to
/// keep track of the log file path manually.
///
/// # Returns
/// A Result that is Ok if the showcase succeeded, or an error if it failed.
///
/// **IMPORTANT**: This function ensures all pending log entries are flushed to disk
/// before showcasing to guarantee the log file is complete.
///
/// # Errors
/// Returns an error if:
/// - No active log file exists
/// - Failed to flush pending log entries
/// - Failed to process the log file
/// - Failed to open the browser
///
/// # Example
///
/// ```no_run
/// use deloxide::{Deloxide, showcase_this};
///
/// // Initialize with logging enabled
/// Deloxide::new()
/// .with_log("deadlock_log.json")
/// .start()
/// .expect("Failed to initialize detector");
///
/// // Later, after a deadlock has been detected
/// showcase_this().expect("Failed to showcase current log");
/// ```