Direct Warning to File#

Synopsis#

Direct itk warnings to a file.

Results#

Output:

Look in itkMessageLog.txt for the output

Code#

C++#

#include <itkFileOutputWindow.h>
#include <itkScaleTransform.h>

int
main(int argc, char * argv[])
{
  using myFileOutputWindow = itk::FileOutputWindow;
  auto window = myFileOutputWindow::New();

  if (argc > 1)
  {
    window->SetFileName(argv[1]);
  }
  window->FlushOn();

  // Set the singelton instance
  itk::OutputWindow::SetInstance(window);

  // Generic output
  itkGenericOutputMacro("This should be in the file: " << window->GetFileName());
  // Warning
  using TransformType = itk::ScaleTransform<float, 2>;
  auto                               transform = TransformType::New();
  TransformType::FixedParametersType parameters(3);
  transform->SetFixedParameters(parameters);

  std::cout << "Look in " << window->GetFileName() << " for the output" << std::endl;
  return EXIT_SUCCESS;
}

Classes demonstrated#

class FileOutputWindow : public itk::OutputWindow

Messages sent from the system are sent to a file.

Text messages that the system should display to the user are sent to this object (or subclasses of this object) and are logged to a file.

ITK Sphinx Examples:

Subclassed by itk::XMLFileOutputWindow

See itk::FileOutputWindow for additional documentation.