Example #1
0
Logger::~Logger() {
  const string filename = Logger::fn_map_[kind_];
  ofstream out(filename, ofstream::app);
  if (!out) {
    clog << "Unable to open log file: '" << filename << "'" << endl;
  } else {
    out << stream_.str() << endl;
  }
  display_fn_(stream_.str());
}
Example #2
0
Logger::~Logger() {
  const string filename = Logger::fn_map_[kind_];
  if (!filename.empty()) {
    // Only try to log to a file if the filename isn't empty.
    // Otherwise just log to the screen.
    ofstream out(filename, ofstream::app);
    if (!out) {
      clog << "Unable to open log file: '" << filename << "'" << endl;
    } else {
      out << stream_.str() << endl;
    }
  }
  display_fn_(stream_.str());
}