MCPcopy Create free account
hub / github.com/GCWing/BitFun / rename_file_to_dated

Method rename_file_to_dated

src/apps/cli/src/logging.rs:127–144  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

125 }
126
127 fn rename_file_to_dated(&self) -> std::io::Result<()> {
128 let to = self.dir.join(format!(
129 "{}_{}.log",
130 self.file_name,
131 Local::now().format(ROTATED_LOG_TIME_FORMAT)
132 ));
133
134 if to.is_file() {
135 let mut to_bak = to.clone();
136 to_bak.set_file_name(format!(
137 "{}.bak",
138 to_bak.file_name().unwrap().to_string_lossy()
139 ));
140 fs::rename(&to, to_bak)?;
141 }
142
143 fs::rename(&self.path, &to)
144 }
145}
146
147impl Write for RotatingFile {

Callers 1

rotateMethod · 0.80

Calls 4

renameFunction · 0.85
joinMethod · 0.45
is_fileMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected