#ifndef WWWI_MIND_MINDLOG_H
#define WWWI_MIND_MINDLOG_H
#include <ostream>
#include "mind.h"
#include "wwwi/mutex.h"
using WWWI::Mutex;
#ifdef DEBUG_ENABLED
#define DEBUG_LOG(XXX) MIND_LOG(XXX)
#define DEBUG_ONLY(XXX) XXX
#else
#define DEBUG_LOG(XXX)
#define DEBUG_ONLY(XXX)
#endif
#define MIND_LOG(XXX) GetSingleton<MINDLog>()->Log(XXX)
typedef enum { LF_UDP,
LF_CACHE,
LF_CEXPIRE,
LF_OBJNEWDEL,
LF_RESOLVER,
LF_MISC,
LF_PACKETFORMAT,
LF_THREADS,
LF_MAX
} LogFacility;
typedef enum { LY_EXTRA_DEBUG,
LY_DEBUG,
LY_INFO,
LY_ERROR,
LY_FAILURE
} LogPriority;
typedef enum { LM_TERMINAL,
LM_SYSLOG
} LogMethod;
class MINDLog {
public:
MINDLog(void);
void Log(LogFacility i_lf, LogPriority i_ly, const char *i_strMessage);
inline void SetMethod(LogMethod i_lm);
inline void SetPriority(LogPriority i_lyAll);
inline void SetPriority(LogFacility i_lf, LogPriority i_ly);
inline void SetStream(ostream *i_smp);
inline bool WouldLog(LogFacility i_lf, LogPriority i_ly);
~MINDLog(void);
protected:
inline int SyslogPri(LogPriority i_ly);
protected:
LogMethod m_lm;
LogPriority *m_lya;
ostream *m_smp;
Mutex m_mx;
};
typedef MINDLog *MINDLogPtr;
inline void FastLog(LogFacility i_lf, LogPriority i_ly, const char *i_strMessage);
#include "mindlog.i"
#endif