Skip to content

Use log level for image writing progress messages.#1448

Closed
jakeforster wants to merge 1 commit into
SuperElastix:mainfrom
jakeforster:main
Closed

Use log level for image writing progress messages.#1448
jakeforster wants to merge 1 commit into
SuperElastix:mainfrom
jakeforster:main

Conversation

@jakeforster

Copy link
Copy Markdown
  • Core/ComponentBaseClasses/elxResamplerBase.hxx (WriteResultImage): Use log::info instead of log::to_stdout.
  • Core/ComponentBaseClasses/elxFixedImagePyramidBase.hxx (WritePyramidImage): Likewise.
  • Core/ComponentBaseClasses/elxMovingImagePyramidBase.hxx (WritePyramidImage): Likewise.

* Core/ComponentBaseClasses/elxResamplerBase.hxx (WriteResultImage):
Use log::info instead of log::to_stdout.
* Core/ComponentBaseClasses/elxFixedImagePyramidBase.hxx
(WritePyramidImage): Likewise.
* Core/ComponentBaseClasses/elxMovingImagePyramidBase.hxx
(WritePyramidImage): Likewise.
if (showProgress)
{
log::to_stdout(" Writing image ...");
log::info(" Writing image ...");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your pull request, @jakeforster However, I'm not sure. These three log::to_stdout(" Writing image ...") calls were really there to ensure that the messages are only printed to the console (not the log file). They are actually the only three use cases of log::to_stdout.

The print statement in ResamplerBase::WriteResultImage was originally added by commit 517406d, July 25, 2008 (before I got involved with elastix):

xl::xout["coutonly"] << "\n  Writing image ..." << std::endl;

xl::xout["coutonly"] << "\n Writing image ..." << std::endl;

"coutonly" suggests that it should not go to the log file.

However, there could certainly be room for improvement. @jakeforster What problem exactly do you want to solve with your pull request?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Niels, the problem is that these messages do not respect the log level. If the user sets the log level to warn or error, it is presumably because they do not want progress messages like these to be shown.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jakeforster Thanks, I see your point.

Your current pull request has the "side effect" that it places those " Writing image ..." messages in the log file, whereas I think they were only meant to inform an interactive user of the progress, while elastix is running.

Instead, as a compromise, we could replace log::to_stdout with a new function, log::info_to_stdout, which would only use stdout, and only when the log level is info (so the most verbose level). What do you think?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me. Thanks for your time.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's another case we may then need to reconsider. ProgressCommand::PrintProgress unconditionally prints the progress percentage to std::cout as well. I'll have another look later this week. Please remind me, if necessary 😃

N-Dekker added a commit that referenced this pull request Jun 3, 2026
`log::info_to_stdout(message)` respects the log level: it only prints the message when the log level is `info`.

Inspired by pull request #1448 "Use log level for image writing progress messages", jakeforster, May 31, 2026.
@N-Dekker

N-Dekker commented Jun 3, 2026

Copy link
Copy Markdown
Member

Of course, my pull request was very much inspired by yours, so thanks very much @jakeforster ! 👍

@N-Dekker N-Dekker closed this Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants