2004-04-14 23:52:59 +02:00
|
|
|
#ifndef _ps_CLogger_H
|
|
|
|
#define _ps_CLogger_H
|
|
|
|
|
|
|
|
#include <fstream>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#define LOG (CLogger::GetInstance()->Log)
|
|
|
|
|
|
|
|
enum ELogMethod
|
|
|
|
{
|
|
|
|
NORMAL,
|
|
|
|
MESSAGE=NORMAL,
|
|
|
|
ERROR,
|
|
|
|
WARNING
|
|
|
|
};
|
|
|
|
|
|
|
|
class CLogger
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
//Function used to get instance of CLogger
|
|
|
|
static CLogger *GetInstance();
|
|
|
|
virtual ~CLogger();
|
|
|
|
|
|
|
|
//Functions to write different message types
|
2004-08-15 22:57:04 +02:00
|
|
|
void WriteMessage(const char *message, int interestedness);
|
|
|
|
void WriteError (const char *message, int interestedness);
|
|
|
|
void WriteWarning(const char *message, int interestedness);
|
2004-04-14 23:52:59 +02:00
|
|
|
|
|
|
|
//Function to log stuff to file
|
2004-08-15 22:57:04 +02:00
|
|
|
void Log(ELogMethod method, const char* category, const char *fmt, ...);
|
2004-04-14 23:52:59 +02:00
|
|
|
|
|
|
|
//Function to log stuff to memory buffer
|
|
|
|
void QuickLog(const char *fmt, ...);
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
CLogger();
|
2004-06-21 18:29:47 +02:00
|
|
|
CLogger(const CLogger& init);
|
|
|
|
CLogger& operator=(const CLogger& rhs);
|
2004-04-14 23:52:59 +02:00
|
|
|
|
2004-08-15 22:57:04 +02:00
|
|
|
//the three filestreams
|
2004-04-14 23:52:59 +02:00
|
|
|
std::ofstream m_MainLog;
|
2004-08-15 22:57:04 +02:00
|
|
|
std::ofstream m_InterestingLog;
|
|
|
|
std::ofstream m_MemoryLog;
|
2004-04-14 23:52:59 +02:00
|
|
|
|
|
|
|
//vars to hold message counts
|
|
|
|
int m_NumberOfMessages;
|
|
|
|
int m_NumberOfErrors;
|
|
|
|
int m_NumberOfWarnings;
|
|
|
|
|
2004-08-15 22:57:04 +02:00
|
|
|
// Returns how interesting this category is to the user
|
|
|
|
// (0 = no messages, 1(default) = warnings/errors, 2 = all)
|
|
|
|
int Interestedness(const char* category);
|
|
|
|
|
2004-04-14 23:52:59 +02:00
|
|
|
//this holds the start of the memory buffer.
|
2004-08-15 22:57:04 +02:00
|
|
|
char *m_MemoryLogBuffer;
|
2004-04-14 23:52:59 +02:00
|
|
|
//this holds the next available place to write to.
|
|
|
|
char *m_CurrentPosition;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|