Listing 4

// 3LogToFile.cpp

class LogToFile: public ErrorLogger
{
public:
  explicit LogToFile( const string& path )
    : ofs_(path.c_str()) {}
  virtual void Log( const string& msg )
  {
    ofs_ << msg;
  }
  // Error() not overridden, still goes to cout
private:
  ofstream ofs_;
};