-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(csi/controller): increase info level logging
This will trace most requests and their completions as info. Signed-off-by: Tiago Castro <[email protected]>
- Loading branch information
1 parent
e03a827
commit aaf7d3c
Showing
3 changed files
with
94 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/// A csi request which can be traced. | ||
pub struct CsiRequest<'a> { | ||
request: &'a str, | ||
start: std::time::Instant, | ||
} | ||
|
||
impl<'a> CsiRequest<'a> { | ||
/// Add new request and info trace it. | ||
pub fn new_info(request: &'a str) -> Self { | ||
tracing::info!("[ CSI ] {request} Request started"); | ||
|
||
Self::new(request) | ||
} | ||
/// Add new request and debug trace it. | ||
pub fn new_dbg(request: &'a str) -> Self { | ||
tracing::debug!("[ CSI ] {request} Request started"); | ||
|
||
Self::new(request) | ||
} | ||
/// Add new request and trace trace it. | ||
pub fn new_trace(request: &'a str) -> Self { | ||
tracing::trace!("[ CSI ] {request} Request started"); | ||
|
||
Self::new(request) | ||
} | ||
|
||
fn new(request: &'a str) -> Self { | ||
Self { | ||
request, | ||
start: std::time::Instant::now(), | ||
} | ||
} | ||
|
||
/// Get completion log message. | ||
pub fn log_str(self) -> String { | ||
format!( | ||
"[ CSI ] {} Request completed successfully after {:?}", | ||
self.request, | ||
self.start.elapsed() | ||
) | ||
} | ||
|
||
/// Log completion info. | ||
pub fn info_ok(self) { | ||
tracing::info!("{}", self.log_str()) | ||
} | ||
} |