Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
GrayLib::cLogFileDay Class Reference

#include <cLogFileDay.h>

Inheritance diagram for GrayLib::cLogFileDay:
Gray::cStreamOutput Gray::cStreamBase GrayLib::cLogAppendFile

Public Member Functions

 cLogFileDay (const FILECHAR_t *pszFileFormat=_FN("log%s") _FN(MIME_EXT_log), int iLogKeepDays=0)
 
virtual ~cLogFileDay ()
 
bool isLogOpen () const
 
cStringF get_LogPath () const
 
cStringF get_LogDir () const
 
HRESULT put_LogDir (cStringF sDir)
 
void CloseLog ()
 
HRESULT OpenLog ()
 
void DeleteOldLogs ()
 
virtual HRESULT WriteString (const LOGCHAR_t *pszMsg) override
 
virtual HRESULT FlushX () override
 
- Public Member Functions inherited from Gray::cStreamOutput
 cStreamOutput () noexcept
 
virtual ~cStreamOutput ()
 
virtual HRESULT WriteX (const void *pData, size_t nDataSize)
 
HRESULT WriteT (const void *pVal, size_t nDataSize)
 
template<typename TYPE >
HRESULT WriteT (TYPE val)
 
HRESULT WriteSize (size_t nSize)
 
HRESULT WriteHashCode (HASHCODE_t nHashCode)
 
HRESULT WriteN (const void *pBuffer, size_t nSize)
 
template<typename _CH >
HRESULT WriteStringN (const _CH *pszStr)
 
template<typename _CH >
HRESULT WriteCharRepeat (_CH nChar, int nCount=1)
 
virtual HRESULT WriteString (const wchar_t *pszStr)
 
StrLen_t VPrintf (const char *pszFormat, va_list args)
 
StrLen_t VPrintf (const wchar_t *pszFormat, va_list args)
 
StrLen_t _cdecl Printf (const char *pszFormat,...)
 
StrLen_t _cdecl Printf (const wchar_t *pszFormat,...)
 
HRESULT WriteStream (cStreamInput &sInp, STREAM_POS_t nSizeMax=k_FILE_BLOCK_SIZE, IStreamProgressCallback *pProgress=nullptr, TIMESYSD_t nTimeout=0)
 Copy cStreamInput to this stream. More...
 
- Public Member Functions inherited from Gray::cStreamBase
virtual ~cStreamBase ()
 
virtual STREAM_SEEKRET_t Seek (STREAM_OFFSET_t iOffset, SEEK_ORIGIN_TYPE eSeekOrigin=SEEK_Set)
 
void SeekToBegin ()
 
STREAM_POS_t SeekToEnd ()
 
virtual STREAM_POS_t GetPosition () const
 
virtual STREAM_POS_t GetLength () const
 

Static Public Member Functions

static cStringF GRAYCALL GetDefaultLogDir ()
 

Public Attributes

cFile m_LogFile
 Place new logged events here. text file. More...
 
int m_iLogKeepDays
 Only keep logs for this many days. then delete file. 0 = forever. More...
 
bool m_bLockOpenClose
 Locked in the current OpenLogCheck or close state. More...
 

Protected Member Functions

cStringF MakeLogPath (const FILECHAR_t *pszFileBaseDir, const FILECHAR_t *pszName) const
 
HRESULT OpenLogNew (const cTimeUnits &rTu)
 
HRESULT OpenLogCheck (bool bStampLine)
 

Additional Inherited Members

- Static Public Attributes inherited from Gray::cStreamBase
static const BYTE k_SIZE_MASK = 0x80
 Used for WriteSize() More...
 
static const size_t k_FILE_BLOCK_SIZE = (32 * 1024)
 default arbitrary transfer block size. more than this is NOT more efficient. More...
 

Detailed Description

A log file that has a new file for each day. Auto delete old log files daily according to an aging policy rule. m_iLogKeepDays

Constructor & Destructor Documentation

◆ cLogFileDay()

GrayLib::cLogFileDay::cLogFileDay ( const FILECHAR_t pszFileFormat = _FN("log%s") _FN(MIME_EXT_log),
int  iLogKeepDays = 0 
)

Do NOT write/Open file until actually used. based on cLogNexus m_Filter.put_LogLevel( LOGLEV_INFO );

◆ ~cLogFileDay()

GrayLib::cLogFileDay::~cLogFileDay ( )
virtual

Member Function Documentation

◆ CloseLog()

void GrayLib::cLogFileDay::CloseLog ( )

◆ DeleteOldLogs()

void GrayLib::cLogFileDay::DeleteOldLogs ( )

Delete all log files older than a certain date. m_iLogKeepDays

  • timeNow = current date/time.

◆ FlushX()

virtual HRESULT GrayLib::cLogFileDay::FlushX ( )
inlineoverridevirtual

Reimplemented from Gray::cStreamOutput.

◆ get_LogDir()

cStringF GrayLib::cLogFileDay::get_LogDir ( ) const
inline

◆ get_LogPath()

cStringF GrayLib::cLogFileDay::get_LogPath ( ) const
inline

ASSUME isLogOpen();

◆ GetDefaultLogDir()

cStringF GRAYCALL GrayLib::cLogFileDay::GetDefaultLogDir ( )
static

◆ isLogOpen()

bool GrayLib::cLogFileDay::isLogOpen ( ) const
inline

◆ MakeLogPath()

cStringF GrayLib::cLogFileDay::MakeLogPath ( const FILECHAR_t pszFileBaseDir,
const FILECHAR_t pszName 
) const
protected
  • = pszFileBaseDir = use this alternative path instead of m_sFileBaseDir. (else leave nullptr)

◆ OpenLog()

HRESULT GrayLib::cLogFileDay::OpenLog ( )

◆ OpenLogCheck()

HRESULT GrayLib::cLogFileDay::OpenLogCheck ( bool  bStampLine)
protected

Make sure the log file is open. Append existing file or create new one. If the day changes create a new log. Don't log anything if cAppState::isInCInit()

Returns
HRESULT.

◆ OpenLogNew()

HRESULT GrayLib::cLogFileDay::OpenLogNew ( const cTimeUnits rTu)
protected

Open my log file for writing. Watch for day change (so we can change the name)

◆ put_LogDir()

HRESULT GrayLib::cLogFileDay::put_LogDir ( cStringF  sDir)

? test if we can create the directory ?

◆ WriteString()

HRESULT GrayLib::cLogFileDay::WriteString ( const LOGCHAR_t pszMsg)
overridevirtual

Reimplemented from Gray::cStreamOutput.

Member Data Documentation

◆ m_bLockOpenClose

bool GrayLib::cLogFileDay::m_bLockOpenClose

Locked in the current OpenLogCheck or close state.

◆ m_iLogKeepDays

int GrayLib::cLogFileDay::m_iLogKeepDays

Only keep logs for this many days. then delete file. 0 = forever.

◆ m_LogFile

cFile GrayLib::cLogFileDay::m_LogFile

Place new logged events here. text file.


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