2021-03-02 02:13:17 +00:00
|
|
|
// Project64 - A Nintendo 64 emulator
|
2021-05-18 11:51:36 +00:00
|
|
|
// https://www.pj64-emu.com/
|
2021-03-02 02:13:17 +00:00
|
|
|
// Copyright(C) 2001-2021 Project64
|
|
|
|
// Copyright(C) 2007 Hiroshi Morii
|
|
|
|
// Copyright(C) 2003 Rice1964
|
|
|
|
// GNU/GPLv2 licensed: https://gnu.org/licenses/gpl-2.0.html
|
2021-05-18 11:51:36 +00:00
|
|
|
|
2013-04-17 10:30:38 +00:00
|
|
|
#define DBG_LEVEL 80
|
|
|
|
|
|
|
|
#include "TxDbg.h"
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdarg.h>
|
2016-01-20 06:09:05 +00:00
|
|
|
#include <Common/StdString.h>
|
2013-04-17 10:30:38 +00:00
|
|
|
#include <Common/path.h>
|
2017-04-26 09:05:05 +00:00
|
|
|
#include <Project64-video/Config.h>
|
|
|
|
#include <Project64-video/Settings.h>
|
2017-01-23 21:11:51 +00:00
|
|
|
|
2013-04-17 10:30:38 +00:00
|
|
|
TxDbg::TxDbg()
|
|
|
|
{
|
2017-01-23 21:34:08 +00:00
|
|
|
const char * log_dir = g_settings->log_dir();
|
2021-04-12 11:35:39 +00:00
|
|
|
if (log_dir != nullptr && log_dir[0] != '\0')
|
2016-03-10 11:14:33 +00:00
|
|
|
{
|
2017-01-23 21:34:08 +00:00
|
|
|
_level = DBG_LEVEL;
|
2016-03-10 11:14:33 +00:00
|
|
|
|
2017-01-23 21:34:08 +00:00
|
|
|
if (!_dbgfile)
|
2013-04-17 10:30:38 +00:00
|
|
|
#ifdef GHQCHK
|
2017-01-23 21:34:08 +00:00
|
|
|
_dbgfile = fopen(CPath(log_dir, "ghqchk.txt"), "w");
|
2013-04-17 10:30:38 +00:00
|
|
|
#else
|
2017-01-23 21:34:08 +00:00
|
|
|
_dbgfile = fopen(CPath(log_dir, "glidehq.dbg"), "w");
|
2013-04-17 10:30:38 +00:00
|
|
|
#endif
|
2017-01-23 21:34:08 +00:00
|
|
|
}
|
2013-04-17 10:30:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TxDbg::~TxDbg()
|
|
|
|
{
|
2017-04-26 10:23:36 +00:00
|
|
|
if (_dbgfile)
|
2017-01-23 21:34:08 +00:00
|
|
|
{
|
2016-02-04 17:31:18 +00:00
|
|
|
fclose(_dbgfile);
|
|
|
|
_dbgfile = 0;
|
|
|
|
}
|
2013-04-17 10:30:38 +00:00
|
|
|
|
2016-02-04 17:31:18 +00:00
|
|
|
_level = DBG_LEVEL;
|
2013-04-17 10:30:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-03-10 11:14:33 +00:00
|
|
|
TxDbg::output(const int level, const char *format, ...)
|
2013-04-17 10:30:38 +00:00
|
|
|
{
|
2016-02-04 17:31:18 +00:00
|
|
|
if (level > _level)
|
|
|
|
return;
|
2013-04-17 10:30:38 +00:00
|
|
|
|
2016-03-10 11:14:33 +00:00
|
|
|
stdstr_f newformat("%d:\t%s", level, format);
|
2013-04-17 10:30:38 +00:00
|
|
|
|
2016-02-04 17:31:18 +00:00
|
|
|
va_list args;
|
|
|
|
va_start(args, format);
|
2016-03-10 11:14:33 +00:00
|
|
|
vfprintf(_dbgfile, newformat.c_str(), args);
|
2016-02-04 17:31:18 +00:00
|
|
|
fflush(_dbgfile);
|
|
|
|
va_end(args);
|
|
|
|
}
|