From 21cb50c82f18b3a2ee1e77a7de11413ce45e6587 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 3 May 2007 23:12:56 +0000 Subject: git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@7 6ecfd1a5-f3ed-3746-8530-beee90d26b22 --- pokemod/Debug.cpp | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'pokemod/Debug.cpp') diff --git a/pokemod/Debug.cpp b/pokemod/Debug.cpp index d160fd2b..4875bd4d 100644 --- a/pokemod/Debug.cpp +++ b/pokemod/Debug.cpp @@ -25,12 +25,11 @@ #ifdef PM_DEBUG -// Declare an instance of the debug window -#ifdef PM_DEBUG_OUTPUT_DEBUG -debugWindow debug = new debugWindow(); +#ifdef PG_DEBUG_WINDOW +extern debugWindow PokeModDebugWindow; #endif -extern int PMdebugLevel; +int PokModDebugLevel; void PokeGen::PokeMod::Log(const char *msg, int level) { @@ -40,23 +39,26 @@ void PokeGen::PokeMod::Log(const char *msg, int level) if (level <= PMdebugLevel) { // Get the current time - time_t curTimeSec = time(NULL); - PMString curTime = asctime(localtime(&curTimeSec)); - curTime.erase(curTime.find('\n')); + char path[21]; + char time[9]; + time_t rawTime = std::time(NULL); + tm *curTime = std::localtime(&rawTime); + strftime(path, 21, "%y/%m-%b/%d-%a", curTime); + strftime(time, 9, "%X", curTime); // Get the actual output message - PMString output("%s (%s): %s", PokeModDebugStr[level], curTime.c_str(), msg); + String output("%s (%s): %s", PokeModDebugStr[level], time, msg); // Output to the command window # ifdef PM_DEBUG_OUTPUT_CONSOLE std::cout << output << std::endl; # endif // Output to the debugging console # ifdef PM_DEBUG_OUTPUT_DEBUG - if (debug.m_Show[level].IsChecked()) - debug.m_Debug.Append(output); + if (PokeModDebugWindow.m_Show[level].IsChecked()) + PokeModDebugWindow.m_Debug.Append(output); # endif // Output to the debugging log # ifdef PM_DEBUG_OUTPUT_FILE - std::ofstream flog("PokeMod.log", std::ios::app); + std::ofstream flog(String("/log/pokemod/%s.log", path), std::ios::app); // Output erros if the file fails if (!flog) { @@ -64,7 +66,7 @@ void PokeGen::PokeMod::Log(const char *msg, int level) std::cout << "Alert (" << curTime << "): Unable to open log file!\n"; # endif # ifdef PM_DEBUG_OUTPUT_DEBUG - debug.m_Debug.Append(String("Alert (%s): Unable to open log file!", curTime)); + PokeModDebugWindow.m_Debug.Append(String("Alert (%s): Unable to open log file!", curTime)); # endif } else @@ -79,7 +81,7 @@ void PokeGen::PokeMod::Log(const char *msg, int level) #else // Empty function if debugging isn't wanted -void PokeGen::PokeMod::Log(const PokeGen::PokeMod::String &msg, int level) +void PokeGen::PokeMod::Log(const String &msg, int level) { return; } -- cgit