Retail products


Traffic interception SDK

Control every TCP/IP network connection

  • Route connections via proxy
  • Redirect connections and modify the data
  • Block connections and applications
SSL interception SDK

View SSL in plaintext and modify it

  • View the SSL stream decrypted in plaintext
  • Redirect SSL connection and modify decrypted data
  • Browser shows "SSL lock" without warnings

Documentation


CFileLog Class Reference

#include <FileLog.h>

Inheritance diagram for CFileLog:
Collaboration diagram for CFileLog:

List of all members.


Public Member Functions

bool WriteLog (const std::string &rData)
void SetMaxLogSize (DWORD dwSize)
void SetLogTruncate (BOOL bTruncate)
BOOL Initialize (const std::string &rFileName)
 CFileLog ()
virtual ~CFileLog ()
void SetAutoFlush (BOOL bFlush)
BOOL GetAutoFlush () const

Protected Member Functions

virtual void WriteError (const std::string &rError)
virtual void WriteMessage (const std::string &rMessage)

Detailed Description

Definition at line 55 of file FileLog.h.


Constructor & Destructor Documentation

KOMODIA_NAMESPACE_START CFileLog::CFileLog (  ) 

Definition at line 54 of file FileLog.cpp.

00054                    : CErrorHandler::CErrorLog(),
00055                        m_pFile(NULL),
00056                        m_pCSection(NULL),
00057                        m_dwMaxLogSize(5000000),
00058                        m_bTruncate(FALSE)
00059 {
00060     //Create the CS
00061     m_pCSection=COSManager::CreateCriticalSection();
00062 }

CFileLog::~CFileLog (  )  [virtual]

Definition at line 64 of file FileLog.cpp.

00065 {
00066     try
00067     {
00068         //Close the file
00069         fclose(m_pFile);
00070 
00071         //Delete the CS
00072         delete m_pCSection;
00073     }
00074     ERROR_UNKNOWN("~CFileLog")
00075 }


Member Function Documentation

BOOL CErrorHandler::CErrorHandler::CErrorLog::GetAutoFlush (  )  const [inherited]

Definition at line 80 of file ErrorHandler.cpp.

00081 {
00082     return m_bAutoFlush;
00083 }

BOOL CFileLog::Initialize ( const std::string &  rFileName  ) 

Definition at line 77 of file FileLog.cpp.

00078 {
00079     //Open's the log file
00080     try
00081     {
00082         //Check if the file is open
00083         if (m_pFile)
00084             //close is
00085             fclose(m_pFile);
00086 
00087         //Which open mode
00088         BOOL bTruncate;
00089         bTruncate=FALSE;
00090 
00091         //Do we need to get the file size
00092         if (m_dwMaxLogSize)
00093         {
00094             //Open the file
00095             HANDLE hFile; 
00096             hFile=CreateFile(rFileName.c_str(),
00097                              GENERIC_READ,
00098                              FILE_SHARE_READ,
00099                              NULL,
00100                              OPEN_EXISTING,
00101                              FILE_ATTRIBUTE_NORMAL,
00102                              NULL);
00103  
00104             //Do we have it?
00105             if (hFile!=INVALID_HANDLE_VALUE) 
00106             { 
00107                 //Get the file size
00108                 DWORD dwSize;
00109                 dwSize=GetFileSize(hFile,
00110                                    NULL);
00111 
00112                 //Close the file
00113                 CloseHandle(hFile);
00114 
00115                 //Is it bigger
00116                 if (dwSize>m_dwMaxLogSize)
00117                     bTruncate=TRUE;
00118             }
00119         }
00120 
00121         //Now open the file
00122         if (!bTruncate)
00123             m_pFile=fopen(rFileName.c_str(),"at");
00124         else
00125             m_pFile=fopen(rFileName.c_str(),"wt");
00126 
00127         //Save the file name
00128         m_sFileName=rFileName;
00129 
00130         //Did we manage to open it?
00131         if (!m_pFile)
00132             return FALSE;
00133         else
00134             return TRUE;
00135     }
00136     ERROR_UNKNOWN_RETURN("ReportError",FALSE)
00137 }

void CErrorHandler::CErrorHandler::CErrorLog::SetAutoFlush ( BOOL  bFlush  )  [inherited]

Definition at line 75 of file ErrorHandler.cpp.

00076 {
00077     m_bAutoFlush=bFlush;
00078 }

void CFileLog::SetLogTruncate ( BOOL  bTruncate  ) 

Definition at line 192 of file FileLog.cpp.

00193 {
00194     m_bTruncate=bTruncate;
00195 }

void CFileLog::SetMaxLogSize ( DWORD  dwSize  ) 

Definition at line 187 of file FileLog.cpp.

00188 {
00189     m_dwMaxLogSize=dwSize;
00190 }

void CFileLog::WriteError ( const std::string &  rError  )  [protected, virtual]

Implements CErrorHandler::CErrorHandler::CErrorLog.

Definition at line 177 of file FileLog.cpp.

00178 {
00179     WriteLog(rError);
00180 }

bool CFileLog::WriteLog ( const std::string &  rData  ) 

Definition at line 139 of file FileLog.cpp.

00140 {
00141     try
00142     {
00143 #ifdef _DEBUG
00144         m_aLog.WriteLog(rData);
00145 #endif
00146         //Lock it
00147         CCriticalAutoRelease aRelease(m_pCSection);
00148     
00149         //Write to log
00150         fprintf(m_pFile,"%s\n",rData.c_str());
00151 
00152         //If error, or auto flush - then flush the data
00153         if (GetAutoFlush())
00154             fflush(m_pFile);
00155 
00156         //Do we need to truncate?
00157         if (m_bTruncate &&
00158             m_dwMaxLogSize &&
00159             ftell(m_pFile)>m_dwMaxLogSize)
00160         {
00161             //Reopen and close the log
00162             //Reinitialize if
00163             Initialize(m_sFileName);
00164 
00165             //Rewrite to the file
00166             WriteLog(CErrorHandler::FormatData("CFileLog",
00167                                                "WriteLog",
00168                                                "Log truncated!"));
00169         }
00170 
00171         //Done
00172         return true;
00173     }
00174     ERROR_UNKNOWN_RETURN("WriteLog",false)
00175 }

void CFileLog::WriteMessage ( const std::string &  rMessage  )  [protected, virtual]

Implements CErrorHandler::CErrorHandler::CErrorLog.

Definition at line 182 of file FileLog.cpp.

00183 {
00184     WriteLog(rMessage);
00185 }


The documentation for this class was generated from the following files: