mirror of
https://github.com/containers/youki
synced 2024-11-23 09:21:57 +01:00
Merge pull request #562 from Furisto/cg-log-data-value
Log value that is written to cgroup file
This commit is contained in:
commit
4dc8863320
@ -100,21 +100,22 @@ pub fn write_cgroup_file_str<P: AsRef<Path>>(path: P, data: &str) -> Result<()>
|
||||
.open(path.as_ref())
|
||||
.with_context(|| format!("failed to open {:?}", path.as_ref()))?
|
||||
.write_all(data.as_bytes())
|
||||
.with_context(|| format!("failed to write to {:?}", path.as_ref()))?;
|
||||
.with_context(|| format!("failed to write {} to {:?}", data, path.as_ref()))?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn write_cgroup_file<P: AsRef<Path>, T: ToString>(path: P, data: T) -> Result<()> {
|
||||
let data = data.to_string();
|
||||
fs::OpenOptions::new()
|
||||
.create(false)
|
||||
.write(true)
|
||||
.truncate(false)
|
||||
.open(path.as_ref())
|
||||
.with_context(|| format!("failed to open {:?}", path.as_ref()))?
|
||||
.write_all(data.to_string().as_bytes())
|
||||
.with_context(|| format!("failed to write to {:?}", path.as_ref()))?;
|
||||
.write_all(data.as_bytes())
|
||||
.with_context(|| format!("failed to write {} to {:?}", data, path.as_ref()))?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user