CoCoALib offers its own "log output stream" for logging messages
(see for instance
obsolescent. By default this is
but it may be set to any other stream (_e.g._
NOTE: internally the implementation uses a global variable, so multi-threaded
applications should be careful about using
LogStream()returns the current CoCoA "log stream" (as a ref to
LogStreamForThisBlock BlockName(out)sets the CoCoA "log stream" (global var) to be
std::ostream) for this code block; it restores previous stream upon exiting the block.
The implementation could hardly be simpler.
The global variable is a pointer because references cannot be reseated in C++
(so it would be impossible to implement
Should the default CoCoA "log stream" be
std::cout is probably easier to deal with for non-expert users
(_e.g._ when redirecting output to a file).