87 static void log(
const std::string& message, Type type = Type::Info, Output output = Output::Console)
89 std::string outstring;
94 outstring =
"INFO: " + message;
97 outstring =
"ERROR: " + message;
100 outstring =
"WARNING: " + message;
104 if (output == Output::Console || output == Output::All)
106 if (type == Type::Error)
110 int outstringLength = outstring.length();
111 char outstring_chararray[outstringLength+1];
112 std::strcpy(outstring_chararray, outstring.c_str());
113 LOGE(
"%s",outstring_chararray);
115 std::cerr << outstring << std::endl;
120 int outstringLength = outstring.length();
121 char outstring_chararray[outstringLength+1];
122 std::strcpy(outstring_chararray, outstring.c_str());
123 LOGI(
"%s", outstring_chararray);
125 std::cout << outstring << std::endl;
127 const std::size_t maxBuffer = 30;
128 buffer().push_back(outstring);
129 if (buffer().size() > maxBuffer)buffer().pop_front();
130 updateOutString(maxBuffer);
134 OutputDebugStringA(outstring.c_str());
137 if (output == Output::File || output == Output::All)
140 std::ofstream file(
"output.log", std::ios::app);
144 std::time_t time = std::time(
nullptr);
145 auto tm = *std::localtime(&time);
147 file.imbue(std::locale());
148 file << std::put_time(&tm,
"%d/%m/%y-%H:%M:%S: ");
150 file << outstring << std::endl;
155 log(message, type, Output::Console);
156 log(
"Above message was intended for log file. Opening file probably failed.", Type::Warning, Output::Console);
175 stringOutput() = stringOutput().substr(stringOutput().find_first_of(
'\n') + 1, stringOutput().size());