Ignore:
Timestamp:
Jul 14, 2014, 8:37:03 PM (11 years ago)
Author:
Frederik Heber <heber@…>
Children:
0ab195
Parents:
ca940b
git-author:
Frederik Heber <heber@…> (06/19/14 16:26:39)
git-committer:
Frederik Heber <heber@…> (07/14/14 20:37:03)
Message:

logger and errorLogger have new setOutputStream().

  • this allows to redirect the logging streams in a program internally, e.g. in a GUI setting.
  • added unit test on this function.
  • TESTFIX: LogUnitTest used loggerStub which made the tests useless.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Helpers/logger.cpp

    rca940b ref9dff6  
    2929int logger::verbosity = 2;
    3030ostream* logger::nix = NULL;
     31ostream* logger::defaultout = NULL;
     32ostream* logger::out = NULL;
    3133
    3234/**
     
    3840{
    3941  nix = new ofstream("/dev/null");
     42  defaultout = &cout;
     43  out = defaultout;
    4044};
    4145
     
    4650{
    4751  delete nix;
     52  out = NULL;   // we are not responsible if out got changed
     53  defaultout = NULL; // do not delete cout
    4854}
    4955
     
    6975}
    7076
     77/** Sets a new output stream.
     78 *
     79 * \param _newout new output stream, if NULL we set to defaultout
     80 */
     81void logger::setOutputStream(ostream *_newout)
     82{
     83  if(_newout != NULL)
     84    out = _newout;
     85  else
     86    out = defaultout;
     87}
     88
    7189/**
    7290 * Operator for the Binary(arg) call.
     
    83101  l.nix->clear();
    84102  if (v.DoOutput(verbosityLevel)) {
    85     v.print(cout);
    86     return cout;
     103    v.print(*logger::out);
     104    return *logger::out;
    87105  } else
    88106    return *l.nix;
     
    93111  l->nix->clear();
    94112  if (v.DoOutput(verbosityLevel)) {
    95     v.print(cout);
    96     return cout;
     113    v.print(*logger::out);
     114    return *logger::out;
    97115  } else
    98116    return *l->nix;
Note: See TracChangeset for help on using the changeset viewer.