Original Post
Hi all, I just want to know how I can write to "stderr" logfile to help debug my game. Thanks, Joshua P.S. I mean a standard function, not an "open, write, close" file system.
#ifndef LOG_H#define LOG_H#include <iostream>#include <fstream>#include <cstring>using namespace std;class LOG{ public: void CreateLog(); void Write(string); void CloseLog(); private: ofstream log_file;};extern LOG logfile;#endif#include <iostream>#include <cstring>#include "log.h"using namespace std;LOG logfile;void LOG::CreateLog(){ log_file.open("log.txt", ios_base::out | ios_base::app); if(!log_file) cout<< "Error Creating log file";}void LOG::Write(string logtext){ log_file << logtext << endl;}void LOG::CloseLog(){ log_file.close();}This topic has been locked by a moderator. New replies are not allowed.
With your permission, GameDev.net uses analytics cookies to understand how people use the platform. You can accept analytics or continue with necessary cookies only. Learn more