Logger: go back to outputting to the console.

Considering I went back to Windows, this is gonna be better than
outputting to a file.
This commit is contained in:
Guillaume Jacquemin 2023-10-29 15:24:27 +01:00
parent 389dabfc77
commit 938bf7b8b5
2 changed files with 15 additions and 3 deletions

View file

@ -16,10 +16,12 @@
#include <iostream>
#ifndef SAVETOOL_DEBUG_BUILD
#include <Corrade/Containers/Optional.h>
#include <Corrade/Containers/Pair.h>
#include <Corrade/Utility/Debug.h>
#include <Corrade/Utility/Path.h>
#endif
#include <Corrade/Utility/Debug.h>
#include "Logger.h"
@ -36,9 +38,9 @@ Logger::instance() {
void
Logger::initialise() {
#ifndef SAVETOOL_DEBUG_BUILD
auto exe_path = Utility::Path::split(*Utility::Path::executableLocation()).first();
_logFile.open(Utility::Path::join(exe_path, "SaveToolLog.txt").cbegin(), std::ios::trunc);
#ifndef SAVETOOL_DEBUG_BUILD
_logFile << "In case you encounter a bug:\n" <<
"1. Do not run the Save Tool again, as this log will be cleared.\n" <<
"2. Go to either the official Sekai Project Discord guild, or the community M.A.S.S. Builder one.\n" <<
@ -63,7 +65,13 @@ Logger::unindent() {
void
Logger::log(EntryType type, StringView location, StringView message) {
Debug d{&_logFile};
Debug d{
#ifdef SAVETOOL_DEBUG_BUILD
&std::cout
#else
&_logFile
#endif
};
switch(type) {
case EntryType::Info:

View file

@ -18,7 +18,9 @@
#include <ctime>
#ifndef SAVETOOL_DEBUG_BUILD
#include <fstream>
#endif
#include <mutex>
#include <Corrade/Containers/String.h>
@ -58,7 +60,9 @@ class Logger {
private:
Logger() = default;
#ifndef SAVETOOL_DEBUG_BUILD
std::ofstream _logFile;
#endif
std::uint32_t _indentLevel = 0;