2017-04-26 10:23:36 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* *
|
|
|
|
* Project64-video - A Nintendo 64 gfx plugin. *
|
|
|
|
* http://www.pj64-emu.com/ *
|
|
|
|
* Copyright (C) 2017 Project64. All rights reserved. *
|
|
|
|
* Copyright (C) 2007 Hiroshi Morii *
|
|
|
|
* Copyright (C) 2003 Rice1964 *
|
|
|
|
* *
|
|
|
|
* License: *
|
|
|
|
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
|
|
|
|
* version 2 of the License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
****************************************************************************/
|
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();
|
|
|
|
if (log_dir != NULL && 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);
|
|
|
|
}
|