project64/Source/GlideHQ/TxDbg.cpp

74 lines
1.8 KiB
C++
Raw Normal View History

2013-04-17 10:30:38 +00:00
/*
* Texture Filtering
* Version: 1.0
*
* Copyright (C) 2007 Hiroshi Morii All Rights Reserved.
* Email koolsmoky(at)users.sourceforge.net
* Web http://www.3dfxzone.it/koolsmoky
*
* this is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* this is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#define DBG_LEVEL 80
#include "TxDbg.h"
#include <string.h>
#include <stdarg.h>
#include <Common/StdString.h>
2013-04-17 10:30:38 +00:00
#include <Common/path.h>
#include <Glide64/Config.h>
2017-01-23 21:34:08 +00:00
#include <Glide64/Settings.h>
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')
{
2017-01-23 21:34:08 +00:00
_level = DBG_LEVEL;
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-01-23 21:34:08 +00:00
if (_dbgfile)
{
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
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
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);
vfprintf(_dbgfile, newformat.c_str(), args);
2016-02-04 17:31:18 +00:00
fflush(_dbgfile);
va_end(args);
}