ENH: improve flexibility of error, messageStream output

- provide a plain stream() method on messageStream to reduce reliance
  on casting operators and slightly opaque operator()() calls etc

- support alternative stream for messageStream serial output.
  This can be used to support local redirection of output.
  For example,

     refPtr<OFstream> logging;   // or autoPtr, unique_ptr etc

     // Later...
     Info.stream(logging.get())
        << "Detailed output ..." << endl;

  This will use the stdout semantics in the normal case, or allow
  redirection to an output file if a target output stream is defined,
  but still effectively use /dev/null on non-master processes.

  This is mostly the same as this ternary

      (logging ? *logging : Info())

  except that the ternary could be incorrect on sub-processes,
  requires more typing etc.

ENH: use case-relative names of dictionary, IOstream for FatalIOError

- normally yields more easily understandable information
This commit is contained in:
Mark Olesen
2021-11-01 12:36:45 +01:00
parent 1c354ce299
commit c9333a5ac8
17 changed files with 337 additions and 187 deletions

View File

@ -474,7 +474,7 @@ int main(int argc, char *argv[])
}
else
{
Info().precision(8);
Info.stream().precision(8);
}
@ -498,7 +498,7 @@ int main(int argc, char *argv[])
else
{
// Report position/angle
auto& os = Info();
auto& os = Info.stream();
os.writeEntry("time", currTime);
state.writeDict(os);

View File

@ -520,7 +520,7 @@ int main(int argc, char *argv[])
}
else
{
Info().precision(8);
Info.stream().precision(8);
}
@ -544,7 +544,7 @@ int main(int argc, char *argv[])
else
{
// Report position/angle
auto& os = Info();
auto& os = Info.stream();
os.writeEntry("time", currTime);
state.writeDict(os);