This is a library intendeted for making logging intermediary results of operations simpler, while also adding context to the current state of operations. Here are some code samples to show the library could be used:
Start by adding the macro calls to where you wan't it's definition in:
loggingcontent::traitLogContent!(); loggingcontent::traitLogDisplay!(); loggingcontent::implResult!();
And define how you wan't kown types to be displayed when logging:
impl
Then you can easily add some log calls without changing anything inside your Result
type.
// Import LogContent trait from where it was defined use utils::log::LogContent;
let mut input = utils::io::timedbufreader( chunksize, fs::File::open(source).logerrormsg("failed to open source file")?, ); input.seek(SeekFrom::Start(skip)).logerrormsg("failed to seek source file")?; let mut output = utils::io::timedbufwriter( chunksize, fs::OpenOptions::new() .read(true) .write(true) .truncate(truncate) .open(device) .logerrormsg("failed to open output file")?, ); output.seek(SeekFrom::Start(seek)).logerrormsg("failed to seek output file")?;
The [[examples/resultlogging.rs][resultlogging]] example shows a more self contained example.