log.cpp

00001 #include <iostream> 00002 #include "gm/log.h" 00003 00004 namespace GNUMessenger { 00005 using namespace std; 00006 00007 LogBase::LogBase(): m_mode(Normal), m_lastWasWide(false) 00008 {} 00009 00010 void LogBase::SetMode(const Mode mode) { 00011 m_mode = mode; 00012 } 00013 00014 const char * LogBase::GetMode() { 00015 switch (m_mode) { 00016 case (Debug): return "GMDEBUG: "; 00017 case (Error): return "GMERROR: "; 00018 case (Normal): return "GMNORMAL: "; 00019 default: return "GM: "; 00020 }; 00021 } 00022 00023 LogManager::LogManager() { 00024 m_logger = new StdLog(); 00025 } 00026 00027 LogManager::~LogManager() { 00028 delete m_logger; 00029 } 00030 00032 void LogManager::SetLog(LogBase * logger) { 00033 if (logger == NULL) 00034 return; 00035 00036 delete m_logger; 00037 m_logger = logger; 00038 } 00039 00040 LogBase& LogManager::operator << (const char * str) { 00041 m_logger->SetMode(LogBase::Normal); 00042 *m_logger << str; 00043 return *m_logger; 00044 } 00045 00046 LogBase& LogManager::operator << (const wchar_t* wstr) { 00047 m_logger->SetMode(LogBase::Normal); 00048 *m_logger << wstr; 00049 return *m_logger; 00050 } 00051 00052 LogBase& LogManager::Debug() { 00053 m_logger->SetMode(LogBase::Debug); 00054 return *m_logger; 00055 } 00056 00057 LogBase& LogManager::Error(){ 00058 m_logger->SetMode(LogBase::Error); 00059 return *m_logger; 00060 } 00061 00062 LogBase& LogManager::Normal() { 00063 m_logger->SetMode(LogBase::Normal); 00064 return *m_logger; 00065 } 00066 00067 }

Generated on Tue Oct 5 14:41:47 2004 for GNU Messenger by doxygen 1.3.8