2014-12-14 02:37:52 -08:00
|
|
|
#include <3ds.h>
|
|
|
|
|
2014-10-29 23:07:11 -07:00
|
|
|
#include "output.h"
|
|
|
|
|
2014-12-14 02:37:52 -08:00
|
|
|
#include <fstream>
|
2014-11-21 22:24:04 -08:00
|
|
|
|
2015-03-10 01:56:54 +01:00
|
|
|
//#include "common/string_funcs.h"
|
2014-10-29 23:07:11 -07:00
|
|
|
|
2015-03-10 01:56:54 +01:00
|
|
|
static FILE* log_file = nullptr;
|
2014-12-14 02:37:52 -08:00
|
|
|
|
|
|
|
void InitOutput()
|
|
|
|
{
|
|
|
|
sdmcInit();
|
2015-03-10 01:56:54 +01:00
|
|
|
consoleInit(GFX_TOP, nullptr);
|
2014-12-14 02:37:52 -08:00
|
|
|
log_file = fopen("hwtest_log.txt", "w");
|
|
|
|
}
|
|
|
|
|
2015-03-10 01:56:54 +01:00
|
|
|
void Print(const std::string& text)
|
2014-12-14 02:37:52 -08:00
|
|
|
{
|
2015-03-10 01:56:54 +01:00
|
|
|
printf("%s", text.c_str());
|
2014-12-14 02:37:52 -08:00
|
|
|
gfxFlushBuffers();
|
|
|
|
gfxSwapBuffers();
|
2014-10-31 22:20:21 -07:00
|
|
|
}
|
2014-10-29 23:07:11 -07:00
|
|
|
|
2015-03-10 01:56:54 +01:00
|
|
|
void Log(const std::string& text)
|
2014-12-14 02:37:52 -08:00
|
|
|
{
|
2015-03-10 01:56:54 +01:00
|
|
|
Print(text);
|
2014-12-14 02:37:52 -08:00
|
|
|
LogToFile(text);
|
2014-10-31 22:20:21 -07:00
|
|
|
}
|
|
|
|
|
2014-12-14 02:37:52 -08:00
|
|
|
void LogToFile(const std::string& text)
|
2014-10-31 22:20:21 -07:00
|
|
|
{
|
2014-12-14 02:37:52 -08:00
|
|
|
svcOutputDebugString(text.c_str(), text.length());
|
|
|
|
fprintf(log_file, "%s", text.c_str());
|
2015-03-10 01:56:54 +01:00
|
|
|
fflush(log_file);
|
2014-10-30 00:25:12 -07:00
|
|
|
}
|
2014-10-30 14:55:01 -07:00
|
|
|
|
2014-12-14 02:37:52 -08:00
|
|
|
void DeinitOutput()
|
2014-10-30 14:55:01 -07:00
|
|
|
{
|
2014-12-14 02:37:52 -08:00
|
|
|
fclose(log_file);
|
2015-03-10 01:56:54 +01:00
|
|
|
log_file = nullptr;
|
2014-12-14 02:37:52 -08:00
|
|
|
sdmcExit();
|
2014-10-30 14:55:01 -07:00
|
|
|
}
|