I would like to create a flexible journal class. I want it to be able to output data to a file or to standard output. In addition, I want to use streams. The class should look something like this:
class Logger
{
private:
std::ostream m_out;
public:
void useFile( std::string fname);
void useStdOut();
void log( symbol_id si, int val );
void log( symbol_id si, std::string str );
};
symbol_id- This listing defines formatting. What I want to achieve is to easily switch from standard output to a file and vice versa (this is the purpose of the methods use*). Preferably, just using m_outand just writing m_out << "something";without any checks, do I want to write to a file or standard output.
, ( if's, , stdout, "C way" ( FILE* fprintf)) .., , , ++ . , . - ?