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

core/debug.cpp File Reference

#include <fstream.h>
#include <time.h>
#include <sys/time.h>
#include "debug.h"
#include "con/print.cpp"

Go to the source code of this file.

Functions

void debug_agent (char *name, T &value, bool logfile=false)

Variables

const char dbgid [] = "\100$ Free Agent: debug.cpp, v 0.1 2002/05/29 red0x Exp $"


Detailed Description

Debugging Subsystem
Include core/debug.cpp when you need
debugging susbsytem functions
DO NOT INCLUDE DEBUG.H, IT WONT LINK
PRPOPERLY. INCLUDE DEBUG.CPP ONLY!

Definition in file debug.cpp.


Function Documentation

void debug_agent ( char * name,
T & value,
bool logfile = false )
 

Debugging output (template function)
This will output the value in "value",
next to the name in "name", along with a time and date.
If logfile is true (LOG_YES), it will output to the default
debug log file (/var/tmp/agent.log)

Parameters:
name   Name to give the value
value   Value to print
logfile   Set to LOG_YES to output to logfile also.

Definition at line 41 of file debug.cpp.

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 }


Variable Documentation

const char dbgid = "\100$ Free Agent: debug.cpp, v 0.1 2002/05/29 red0x Exp $" [static]
 

Definition at line 27 of file debug.cpp.


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