AndrewRadev/id3-image

Disable console output

Closed this issue · 7 comments

Is there an option to disable console output? I wasn't able to find one and I think it should have one. You could use the log crate to log with different levels which can be disabled afterwards: https://crates.io/crates/log.

Generally, I have no problem about building in different verbosity levels. I see that I've already added a --verbose flag to add more output, though. It seems like if the commands succeed, they don't produce output. Do you mean silencing failures as well? I could add a --quiet flag to just exit with an error code with no explanation. Is that what you're looking for?

Additionally, the id3-image-remove tool shows a confirmation prompt -- I'm thinking that would also be avoided in "quiet" mode (though, for this one, there's also --no-confirm)?

I've added a branch called quiet-mode that you could try: https://github.com/AndrewRadev/id3-image/tree/quiet-mode. I haven't used the log crate, because at this time, it feels like it's simpler to just stick to explicit if-clauses... I might try it out later.

A very nice addition! But I mean the output when using it as a library crate in a separate project. My Cargo.toml file contains:

id3-image = "0.1.5"

In my code, I use the library like this:

id3_image::remove_images(path)?;
id3_image::embed_image(path, image_path)?;

And I get an output like this:

location: size=0x92 padding=0x0
location: size=0xe4 padding=0x7f6

This is what I like to disable.
You can look at my code using your library here, file src/metadata.rs line 58 (as of writing this).

Ah, I see. The print statement doesn't seem to be coming from this project, but from the id3 library it depends on: https://github.com/polyfloyd/rust-id3/blob/5cf164079f2277e99dbe1a10c0eed5a82e1df8b8/src/stream/tag.rs#L303-L306

This is from version 0.5.3, which seems to have accidentally left that in, I think? Originally, I set the version to 0.5.1, but it seems cargo is fine with bumping the patch version. Semver is hard.

I tried to update that library to 0.6 (it doesn't have that print statement), but I'm seeing test failures. I'll try to debug the issue tomorrow.

I've updated the id3 crate in master, so if you use that branch, it should work -- could you try it out? If you can confirm it resolves your issue, I'll publish a new release.

It worked, thank you!

Awesome, I've bumped the version to 0.2.0, so you should be able to use that in your Cargo.toml file. I'll consider this issue closed for now, let me know if you run into other problems.