1 #ifndef __PHOTOS_LOG_CLASS_HEADER__ 
    2 #define __PHOTOS_LOG_CLASS_HEADER__ 
   22 using std::stringstream;
 
   72         static void Assert(
bool check, 
char *text=NULL);
 
   76         static void Fatal(
string text, 
unsigned short int code=0);
 
   77         static void Fatal(
unsigned short int code=0)                            { 
Fatal(NULL,code);       }
 
  136 #ifdef _LOG_DEBUG_MODE_ 
  137         static void NewPointer(
unsigned long address,  
unsigned long size,  
const char *
file, 
unsigned long line)
 
  141                         PointerList = 
new list<Pointer *>();
 
  142                         atexit(PrintAllocatedPointers);
 
  148                 strncpy(info->
file, file, 63);
 
  149                 PointerList->push_front(info);
 
  151         static void DeletePointer(
unsigned long address)
 
  153                 if(!PointerList) 
return;
 
  154                 for(list<Pointer*>::iterator 
i = PointerList->begin(); 
i!=PointerList->end(); 
i++)
 
  156                         if((*i)->address == address)
 
  158                                 PointerList->remove((*
i));
 
  163         static bool PointerCompare(Pointer *one, Pointer *two)
 
  165                 int eq = strcmp(one->file,two->file);
 
  166                 if(eq<0) 
return true;
 
  167                 else if(eq>0) 
return false;
 
  168                 return (one->line <= two->line);
 
  170         static void PrintAllocatedPointers()
 
  172                 if(!PointerList) 
return;
 
  173                 int pointers=0,buf=0;
 
  174                 unsigned long total=0;
 
  176                 unsigned int lastL=0;
 
  177                 if(PointerList->size()==0)
 
  179                         cout<<
"----------------------------UNFREED MEMORY POINTERS----------------------------\n";
 
  180                         cout<<
"                                 ... NONE ...\n";
 
  181                         cout<<
"-------------------------------------------------------------------------------\n";
 
  184                 PointerList->sort(PointerCompare);
 
  185                 cout<<
"---------------------------UNFREED MEMORY POINTERS---------------------------\n";
 
  186                 for(list<Pointer*>::iterator 
i = PointerList->begin(); 
i!=PointerList->end(); 
i++)
 
  190                         if(strcmp(lastS,(*i)->file)==0)
 
  192                                 if(lastL==(*i)->line)
 
  194                                         printf(
"%56s%10lub (%lu)\n",
" ",(*i)->size,(*i)->address);
 
  200                         printf(
"%s%n:",(*i)->file,&buf);
 
  201                         printf(
"%-*lu%10lub (%lu)\n",55-buf,(*i)->line,(*i)->size,(*i)->address);
 
  203                 cout<<endl<<total<<
"\tbytes"<<endl;
 
  204                 cout<<pointers<<
"\tpointers"<<endl;
 
  205                 cout<<
"-------------------------------------------------------------------------------\n";
 
  207 #endif //_LOG_DEBUG_MODE_ 
  210 #ifdef _LOG_DEBUG_MODE_ 
  218 inline void* 
operator new(
long unsigned int size, 
const char *
filename, 
int line)
 
  220         void *ptr = (
void *)malloc(size);
 
  221         Photos::Log::NewPointer((
unsigned long)ptr, size, filename, line);
 
  225 inline void  operator delete(
void *
p)
 
  227         Photos::Log::DeletePointer((
unsigned long)
p);
 
  231 #define new new(__FILE__, __LINE__) 
  233 #endif //_LOG_DEBUG_MODE_ 
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
static void Assert(bool check, char *text=NULL)
static void LogPhlupa(int from, int to)
static void LogAll(bool flag=true)
static list< Pointer * > * PointerList
static void SetWarningLimit(int x)
static void AddDecay(int type)
static void Fatal(unsigned short int code=0)
static void IgnoreFailedAssert(bool flag=true)
static void IgnoreFatal(unsigned short s=0, unsigned short e=65535)
static void IgnoreRedirection(bool flag=true)
static ostream & Info(bool count=true)
static ostream & Debug(unsigned short int code=0, bool count=true)
basic_ostream< char, char_traits< char > > ostream
static void LogError(bool flag=true)
static void LogWarning(bool flag=true)
static ostream & Warning(bool count=true)
static void SetOutput(ostream &newOut)
static void SummaryAtExit()
static void Fatal(string text, unsigned short int code=0)
static void LogDebug(unsigned short s=0, unsigned short e=65535)
static void RevertOutput()
static void SetOutput(ostream *newOut)
static void RedirectOutput(void(*func)(), ostream &where=*out)
static void LogInfo(bool flag=true)
static ostream & Error(bool count=true)