123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- //---------------------------------------------------------------------------
- #include "stdafx.h"
- #include "ApiLog.h"
- //////////////////////////////////////////////////////////////////////
- // Konstruktion/Destruktion
- //////////////////////////////////////////////////////////////////////
- CApiLog::CApiLog()
- {
- FIntern = NULL;
- }
- CApiLog::~CApiLog()
- {
- }
- void CApiLog::InitIntern(TFileZillaIntern * Intern)
- {
- FIntern = Intern;
- }
- TFileZillaIntern * CApiLog::GetIntern()
- {
- return FIntern;
- }
- bool CApiLog::LoggingMessageType(int nMessageType) const
- {
- return
- (nMessageType < FZ_LOG_APIERROR) ||
- ((nMessageType-FZ_LOG_APIERROR) < FIntern->GetDebugLevel());
- }
- void CApiLog::LogMessage(int nMessageType, LPCTSTR pMsgFormat, ...) const
- {
- DebugAssert(nMessageType>=FZ_LOG_STATUS && nMessageType<=FZ_LOG_DEBUG);
- if (!LoggingMessageType(nMessageType))
- return;
- va_list ap;
- va_start(ap, pMsgFormat);
- CString text;
- text.FormatV(pMsgFormat, ap);
- va_end(ap);
- if (nMessageType>=FZ_LOG_DEBUG)
- return;
- SendLogMessage(nMessageType, text);
- }
- void CApiLog::LogMessageRaw(int nMessageType, LPCTSTR pMsg) const
- {
- DebugAssert(nMessageType>=FZ_LOG_STATUS && nMessageType<=FZ_LOG_DEBUG);
- if (!LoggingMessageType(nMessageType))
- return;
- if (nMessageType>=FZ_LOG_DEBUG)
- return;
- SendLogMessage(nMessageType, pMsg);
- }
- void CApiLog::LogMessage(int nMessageType, UINT nFormatID, ...) const
- {
- DebugAssert(nMessageType>=FZ_LOG_STATUS && nMessageType<=FZ_LOG_DEBUG);
- if (!LoggingMessageType(nMessageType))
- return;
- CString str;
- str.LoadString(nFormatID);
- va_list ap;
- va_start(ap, nFormatID);
- CString text;
- text.FormatV(str, ap);
- va_end(ap);
- if (nMessageType>=FZ_LOG_DEBUG)
- return;
- SendLogMessage(nMessageType, text);
- }
- void CApiLog::SendLogMessage(int nMessageType, LPCTSTR pMsg) const
- {
- if (!LoggingMessageType(nMessageType))
- return;
- //Displays a message in the message log
- t_ffam_statusmessage *pStatus = new t_ffam_statusmessage;
- pStatus->post = TRUE;
- pStatus->status = pMsg;
- pStatus->type = nMessageType;
- if (!FIntern->PostMessage(FZ_MSG_MAKEMSG(FZ_MSG_STATUS, 0), (LPARAM)pStatus))
- delete pStatus;
- }
- CString CApiLog::GetOption(int OptionID) const
- {
- DebugAssert(FIntern != NULL);
- return FIntern->GetOption(OptionID);
- }
- int CApiLog::GetOptionVal(int OptionID) const
- {
- DebugAssert(FIntern != NULL);
- return FIntern->GetOptionVal(OptionID);
- }
|