1
0
mirror of https://github.com/winscp/winscp.git synced 2026-10-24 02:28:55 +03:00
Files
winscp/source/filezilla/ApiLog.cpp
Martin Prikryl efe94d6c08 Using actual types and functions instead of WinAPI and Unicode/Ansi macros
Source commit: b7fec4d069296b58bb43e7a4a97dd85d558212b7
2025-12-21 01:34:21 +01:00

94 lines
2.2 KiB
C++

//---------------------------------------------------------------------------
#include "FileZillaPCH.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, const wchar_t * 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, const wchar_t * 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::SendLogMessage(int nMessageType, const wchar_t * 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), reinterpret_cast<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);
}
void CApiLog::LogError(int Error)
{
UnicodeString Message = SysErrorMessage(Error);
LogMessageRaw(FZ_LOG_ERROR, Message.c_str());
}