Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

core/debug.cpp

Go to the documentation of this file.
00001 
00018 #include <fstream.h>
00019 #include <time.h>
00020 #include <sys/time.h>
00021 #include "debug.h"
00022 #include "con/print.cpp"
00023 
00024 #ifndef _CORE_DEBUG_CPP_
00025 #define _CORE_DEBUG_CPP_
00026 
00027 static const char dbgid[] = "\100$ Free Agent: debug.cpp, v 0.1 2002/05/29 red0x Exp $";
00028 
00040 template<class T>
00041 void debug_agent(char *name, T& value, bool logfile = false)
00042 {
00043     {assert(name != NULL);}
00044     //{assert(value != NULL);}
00045     time_t tm;
00046     char *stm;
00047     agent_newarr(&stm, 50);
00048     time(&tm);
00049     strftime(stm, 50, "%a %b %e %T %Z %Y", localtime(&tm));
00050     if(logfile)
00051     {
00052 
00053         fstream fp;
00054         fp.open(debug_agent_log_file,ios::out|ios::app);
00055         if(!fp.is_open())
00056             return;
00057 
00058         fp << "[" << stm << "] " << name << ": " << value << ";" << std::endl;
00059         fp.close();
00060         //output name = value;\n
00061     }
00062     //what to do if we dont want to log it...
00063     //print it?
00064     agent_print("[");
00065     agent_print(stm);
00066     agent_print("] ");
00067     agent_print(name);
00068     agent_print(": ");
00069     agent_print(value);
00070     agent_println(";");
00071 }
00072 #endif

Generated at Thu May 30 15:12:33 2002 for Freeagent by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001