mirror of
https://github.com/DaedalusX64/daedalus.git
synced 2025-04-02 10:21:48 -04:00
105 lines
2.8 KiB
C++
105 lines
2.8 KiB
C++
/*
|
|
Copyright (C) 2001 StrmnNrmn
|
|
|
|
This program 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
|
|
of the License, or (at your option) any later version.
|
|
|
|
This program 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 this program; if not, write to the Free Software
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
#include "BuildOptions.h"
|
|
#include "Base/Types.h"
|
|
|
|
#include "Debug/DebugLog.h"
|
|
#include "Debug/Dump.h"
|
|
#include "Debug/DBGConsole.h"
|
|
|
|
#include "System/IO.h"
|
|
|
|
#ifdef DAEDALUS_LOG
|
|
|
|
//*****************************************************************************
|
|
//
|
|
//*****************************************************************************
|
|
static bool g_bLog = false;
|
|
static FILE * g_hOutputLog = NULL;
|
|
|
|
//*****************************************************************************
|
|
//
|
|
//*****************************************************************************
|
|
bool Debug_InitLogging()
|
|
{
|
|
std::filesystem::path log_filename = "daedalus.txt";
|
|
|
|
#ifdef DAEDALUS_DEBUG_CONSOLE
|
|
if ( CDebugConsole::IsAvailable() )
|
|
{
|
|
CDebugConsole::Get()->Msg( 0, "Creating Dump file '%s'", log_filename.c_str() );
|
|
}
|
|
#endif
|
|
g_hOutputLog = fopen( log_filename.c_str(), "w" );
|
|
|
|
return g_hOutputLog != NULL;
|
|
}
|
|
|
|
//*****************************************************************************
|
|
//
|
|
//*****************************************************************************
|
|
void Debug_FinishLogging()
|
|
{
|
|
if( g_hOutputLog )
|
|
{
|
|
fclose( g_hOutputLog );
|
|
g_hOutputLog = NULL;
|
|
}
|
|
}
|
|
|
|
//*****************************************************************************
|
|
//
|
|
//*****************************************************************************
|
|
void Debug_Print( const char * format, ... )
|
|
{
|
|
if(g_bLog && format != NULL )
|
|
{
|
|
char buffer[1024+1];
|
|
char * p = buffer;
|
|
va_list va;
|
|
// Parse the buffer:
|
|
// Format the output
|
|
va_start(va, format);
|
|
// Don't use wvsprintf as it doesn't handle floats!
|
|
vsprintf(p, format, va);
|
|
va_end(va);
|
|
|
|
fprintf( g_hOutputLog, "%s\n", p );
|
|
}
|
|
}
|
|
|
|
//*****************************************************************************
|
|
//
|
|
//*****************************************************************************
|
|
bool Debug_GetLoggingEnabled()
|
|
{
|
|
return g_bLog && (g_hOutputLog != NULL);
|
|
}
|
|
|
|
//*****************************************************************************
|
|
//
|
|
//*****************************************************************************
|
|
void Debug_SetLoggingEnabled( bool enabled )
|
|
{
|
|
g_bLog = enabled;
|
|
}
|
|
|
|
|
|
#endif // DAEDALUS_LOG
|