I have a simple logger class which I tried to turn into accepting and outputting wstrings instead strings.
header:
#include <fstream>
using namespace std;
class CLog
{
public:
CLog(wstring filename);
~CLog();
void WriteString(string uString);
private:
fstream m_stream;
};
cpp:
#include "stdafx.h";
#include "log.h";
CLog::CLog(wstring uPath)
{
m_stream.open(uPath);
}
void CLog::WriteString(string uString)
{
m_stream << uString.c_str() << endl;
}
CLog::~CLog()
{
m_stream.close();
}
Can anybody suggest what I should use instead of fstream? I tried using wstringstream, but it did not even have .open to output it to file, so I thought that is the wrong approach.
I would like to keep the behaviour that it immediately writes to a file.