The C++ framework for developing highly scalable, high performance servers on Windows platforms.

CFixedFileHeaderRotatingAsyncFileLog Class Reference
[Asynchronous I/OInterfacesFileIOLog files and the pluggable logging system]

Inheritance diagram for CFixedFileHeaderRotatingAsyncFileLog:
Collaboration diagram for CFixedFileHeaderRotatingAsyncFileLog:

List of all members.


Detailed Description

A class that implements JetByteTools::ILogMessages to provide an asynchronous file log that uses overlapped I/O to perform writes to the log file. The log can be set to automatically rotate (i.e. create a new log file) after a set period of time or when the file grows to a particular size.

Public Types

enum  IncludeLines {
  NormalLogLines = 0x00, ExplicitLinesOnly = 0x01, AddHeaderToAllFiles = 0x00, AddHeaderToNewFiles = 0x10,
  ExplicitAndNew = ExplicitLinesOnly | AddHeaderToNewFiles
}
typedef unsigned long DataLength
enum  RotationPeriod { NoRotation, Hourly, Daily, Weekly }
enum  FirstFileTimestamp { DoNotIncludeTimestampOnFirstFile, IncludeTimestampOnFirstFile }
enum  EmptyLogFileHandling { PreserveEmptyLogFiles, DeleteEmptyLogFiles }
enum  LogEntryFormat { JustMessage = 0x000, IncludeThreadId = 0x001, IncludeTimestamp = 0x010, IncludeEverything = 0x011 }
typedef unsigned long DataLength
typedef std::vector
< std::string > 
VectorOfLines
 Logs the messages to the log. Note that you should manually synchronise access to this function and the various SetLogName calls.
typedef std::deque
< std::string > 
DequeOfLines
 Logs the messages to the log. Note that you should manually synchronise access to this function and the various SetLogName calls.

Public Member Functions

 CFixedFileHeaderRotatingAsyncFileLog (const JetByteTools::Core::_tstring &filenameBase, RotationPeriod rotationPeriod=Daily, FirstFileTimestamp firstFileTimestamp=IncludeTimestampOnFirstFile, EmptyLogFileHandling emptyLogFileHandling=PreserveEmptyLogFiles, ILimitPendingWrites &writeLimiter=CPendingWriteLimiter::NoLimitLimiter)
 See base class constructor for details.
 CFixedFileHeaderRotatingAsyncFileLog (const JetByteTools::Core::_tstring &filenameBase, IHandleFileCreationFailure &handler, RotationPeriod rotationPeriod=Daily, FirstFileTimestamp firstFileTimestamp=IncludeTimestampOnFirstFile, EmptyLogFileHandling emptyLogFileHandling=PreserveEmptyLogFiles, ILimitPendingWrites &writeLimiter=CPendingWriteLimiter::NoLimitLimiter)
 See base class constructor for details.
 CFixedFileHeaderRotatingAsyncFileLog (const JetByteTools::Core::_tstring &filenameBase, JetByteTools::IO::IAllocateBuffers &allocator, IHandleFileCreationFailure &handler, RotationPeriod rotationPeriod=Daily, FirstFileTimestamp firstFileTimestamp=IncludeTimestampOnFirstFile, EmptyLogFileHandling emptyLogFileHandling=PreserveEmptyLogFiles, ILimitPendingWrites &writeLimiter=CPendingWriteLimiter::NoLimitLimiter)
 See base class constructor for details.
 CFixedFileHeaderRotatingAsyncFileLog (const JetByteTools::Core::_tstring &filenameBase, JetByteTools::Core::IQueueTimers &timerQueue, JetByteTools::IO::IIOPool &pool, JetByteTools::IO::IAllocateBuffers &allocator, RotationPeriod rotationPeriod=Daily, FirstFileTimestamp firstFileTimestamp=IncludeTimestampOnFirstFile, EmptyLogFileHandling emptyLogFileHandling=PreserveEmptyLogFiles, ILimitPendingWrites &writeLimiter=CPendingWriteLimiter::NoLimitLimiter)
 See base class constructor for details.
 CFixedFileHeaderRotatingAsyncFileLog (const JetByteTools::Core::_tstring &filenameBase, IHandleFileCreationFailure &handler, JetByteTools::Core::IQueueTimers &timerQueue, JetByteTools::IO::IIOPool &pool, JetByteTools::IO::IAllocateBuffers &allocator, RotationPeriod rotationPeriod=Daily, FirstFileTimestamp firstFileTimestamp=IncludeTimestampOnFirstFile, EmptyLogFileHandling emptyLogFileHandling=PreserveEmptyLogFiles, ILimitPendingWrites &writeLimiter=CPendingWriteLimiter::NoLimitLimiter)
 See base class constructor for details.
 CFixedFileHeaderRotatingAsyncFileLog (const JetByteTools::Core::_tstring &filenameBase, JetByteTools::Core::IQueueTimers &timerQueue, JetByteTools::IO::IIOPool &pool, JetByteTools::IO::IAllocateBuffers &allocator, const JetByteTools::Core::IProvideLocalTime &timeProvider, RotationPeriod rotationPeriod=Daily, FirstFileTimestamp firstFileTimestamp=IncludeTimestampOnFirstFile, EmptyLogFileHandling emptyLogFileHandling=PreserveEmptyLogFiles, ILimitPendingWrites &writeLimiter=CPendingWriteLimiter::NoLimitLimiter)
 See base class constructor for details.
 CFixedFileHeaderRotatingAsyncFileLog (const JetByteTools::Core::_tstring &filenameBase, IHandleFileCreationFailure &handler, JetByteTools::Core::IQueueTimers &timerQueue, JetByteTools::IO::IIOPool &pool, JetByteTools::IO::IAllocateBuffers &allocator, const JetByteTools::Core::IProvideLocalTime &timeProvider, RotationPeriod rotationPeriod=Daily, FirstFileTimestamp firstFileTimestamp=IncludeTimestampOnFirstFile, EmptyLogFileHandling emptyLogFileHandling=PreserveEmptyLogFiles, ILimitPendingWrites &writeLimiter=CPendingWriteLimiter::NoLimitLimiter)
 See base class constructor for details.
 CFixedFileHeaderRotatingAsyncFileLog (const CFixedFileHeaderRotatingAsyncFileLog &rhs)
 ~CFixedFileHeaderRotatingAsyncFileLog () override
CFixedFileHeaderRotatingAsyncFileLogoperator= (const CFixedFileHeaderRotatingAsyncFileLog &rhs)
void SetLinesToInclude (IncludeLines includeLines) override
void LogFixedHeaderMessage (const std::string &message) override
void LogFixedHeaderMessage (const char *pString) override
void LogFixedHeaderMessage (const char *pString, ILogMessagesWithFixedFileHeader::DataLength stringLength) override
void FixedHeaderComplete () override
void LogMessage (const char *pString, ILogMessages::DataLength stringLength) override
virtual void LogFixedHeaderMessage (const char *pString, DataLength stringLength)=0
void SetLogEntryFormat (DWORD format)
void SetMaxFileSize (__int64 size)
void SetMaxLines (size_t lines)
void SetNextFileNumber (DWORD nextFileNumber)
void SetCallback (CAsyncFileWriter::Callback *pCallback)
 Allows you to specify an optional callback implementation to receive notifications.
bool PerformWritesOnThisThread () const
 Returns true if writes are issued directly from the calling thread and false if they are marshalled to the thread pool.
JetByteTools::Core::_tstring GetCurrentLogFileName () const
 Returns the complete file name of the current log, i.e the filename that was set plus the date/time portion that is generated automatically.
void SetThreadIdentifier (const std::string &identifier) override
 Sets the identifier used in the log for the current thread to the supplied string. The thread identifier defaults to the thread id in the form "XXX: ", the string supplied as an identifier does not need to include the ": " as this will be appended automatically. It can be any string that will help you to identify the thread concerned.
void SetThreadIdentifier (const std::wstring &identifier) override
 Sets the identifier used in the log for the current thread to the supplied string. The thread identifier defaults to the thread id in the form "XXX: ", the string supplied as an identifier does not need to include the ": " as this will be appended automatically. It can be any string that will help you to identify the thread concerned.
void SetLogName (const std::string &filenameBase) override
 Sets the name of the log file using the supplied filenameBase for the base of the log file name; the actual file name is formed as follows: filenameBase-YYYYMMDD-HHMMSS.log. If filenameBase ends with ".log" then this is automatically stripped to leave the actual file name in the form shown above. Note that if the file log was created with includeTimeInFirstFilename set to false then the file name will NOT include the -HHMMSS section. Note that this creates a new log file with the specified name, it does NOT rename the existing log file. All subsequent automatic log file creation will use the newly supplied filenameBase rather than any that was supplied in the constructor.
void SetLogName (const std::wstring &filenameBase) override
 Sets the name of the log file using the supplied filenameBase for the base of the log file name; the actual file name is formed as follows: filenameBase-YYYYMMDD-HHMMSS.log. If filenameBase ends with ".log" then this is automatically stripped to leave the actual file name in the form shown above. Note that if the file log was created with includeTimeInFirstFilename set to false then the file name will NOT include the -HHMMSS section. Note that this creates a new log file with the specified name, it does NOT rename the existing log file. All subsequent automatic log file creation will use the newly supplied filenameBase rather than any that was supplied in the constructor.
void LogMessage (const VectorOfLines &messages) override
 Logs the message to the log.
void LogMessage (const DequeOfLines &messages) override
 Logs the message to the log.
void LogMessage (const std::string &message) override
 Logs the message to the log.
void LogMessage (const std::wstring &message) override
 Logs the message to the log.
void LogMessage (const char *pString) override
 Logs the message to the log.
void LogMessage (const wchar_t *pString) override
 Logs the message to the log.
void LogMessage (const char *pString, DataLength stringLength) override
 Logs the message to the log.
void LogMessage (const wchar_t *pString, DataLength stringLength) override
 Logs the message to the log.
virtual void LogMessage (const char *pString, DataLength stringLength)=0
 Logs the message to the log. Note that you should manually synchronise access to this function and the various SetLogName calls.
virtual void LogMessage (const wchar_t *pString, DataLength stringLength)=0
 Logs the message to the log. Note that you should manually synchronise access to this function and the various SetLogName calls.
HANDLE GetWaitHandle () const override
void Wait () const override
bool Wait (Milliseconds timeoutMillis) const override

Protected Member Functions

CAsyncFileWriterExOnNewFileWriter (CAsyncFileWriterEx *pWriter) override
CAsyncFileWriterExGetFileWriter ()

Member Typedef Documentation

typedef unsigned long DataLength [inherited]

typedef unsigned long DataLength [inherited]

typedef std::vector<std::string> VectorOfLines [inherited]

Logs the messages to the log. Note that you should manually synchronise access to this function and the various SetLogName calls.

typedef std::deque<std::string> DequeOfLines [inherited]

Logs the messages to the log. Note that you should manually synchronise access to this function and the various SetLogName calls.


Member Enumeration Documentation

enum IncludeLines [inherited]

Enumerator:
NormalLogLines 
ExplicitLinesOnly 
AddHeaderToAllFiles 
AddHeaderToNewFiles 
ExplicitAndNew 

enum RotationPeriod [inherited]

Enumerator:
NoRotation 
Hourly 
Daily 
Weekly 

enum FirstFileTimestamp [inherited]

Enumerator:
DoNotIncludeTimestampOnFirstFile 
IncludeTimestampOnFirstFile  The first file does not include a -HHMMSS portion in the file name.

The first file generated includes a timetsamp portion, -HHMMSS in the generated file name.

enum EmptyLogFileHandling [inherited]

Enumerator:
PreserveEmptyLogFiles 
DeleteEmptyLogFiles  Empty log files are created if no logging occurs during a file's active period.

Delete empty log files when they are closed

enum LogEntryFormat [inherited]

Enumerator:
JustMessage 
IncludeThreadId 
IncludeTimestamp 
IncludeEverything 


Constructor & Destructor Documentation

CFixedFileHeaderRotatingAsyncFileLog ( const JetByteTools::Core::_tstring filenameBase,
RotationPeriod  rotationPeriod = Daily,
FirstFileTimestamp  firstFileTimestamp = IncludeTimestampOnFirstFile,
EmptyLogFileHandling  emptyLogFileHandling = PreserveEmptyLogFiles,
ILimitPendingWrites writeLimiter = CPendingWriteLimiter::NoLimitLimiter 
) [explicit]

See base class constructor for details.

CFixedFileHeaderRotatingAsyncFileLog ( const JetByteTools::Core::_tstring filenameBase,
IHandleFileCreationFailure handler,
RotationPeriod  rotationPeriod = Daily,
FirstFileTimestamp  firstFileTimestamp = IncludeTimestampOnFirstFile,
EmptyLogFileHandling  emptyLogFileHandling = PreserveEmptyLogFiles,
ILimitPendingWrites writeLimiter = CPendingWriteLimiter::NoLimitLimiter 
)

See base class constructor for details.

CFixedFileHeaderRotatingAsyncFileLog ( const JetByteTools::Core::_tstring filenameBase,
JetByteTools::IO::IAllocateBuffers allocator,
IHandleFileCreationFailure handler,
RotationPeriod  rotationPeriod = Daily,
FirstFileTimestamp  firstFileTimestamp = IncludeTimestampOnFirstFile,
EmptyLogFileHandling  emptyLogFileHandling = PreserveEmptyLogFiles,
ILimitPendingWrites writeLimiter = CPendingWriteLimiter::NoLimitLimiter 
)

See base class constructor for details.

CFixedFileHeaderRotatingAsyncFileLog ( const JetByteTools::Core::_tstring filenameBase,
JetByteTools::Core::IQueueTimers timerQueue,
JetByteTools::IO::IIOPool pool,
JetByteTools::IO::IAllocateBuffers allocator,
RotationPeriod  rotationPeriod = Daily,
FirstFileTimestamp  firstFileTimestamp = IncludeTimestampOnFirstFile,
EmptyLogFileHandling  emptyLogFileHandling = PreserveEmptyLogFiles,
ILimitPendingWrites writeLimiter = CPendingWriteLimiter::NoLimitLimiter 
)

See base class constructor for details.

CFixedFileHeaderRotatingAsyncFileLog ( const JetByteTools::Core::_tstring filenameBase,
IHandleFileCreationFailure handler,
JetByteTools::Core::IQueueTimers timerQueue,
JetByteTools::IO::IIOPool pool,
JetByteTools::IO::IAllocateBuffers allocator,
RotationPeriod  rotationPeriod = Daily,
FirstFileTimestamp  firstFileTimestamp = IncludeTimestampOnFirstFile,
EmptyLogFileHandling  emptyLogFileHandling = PreserveEmptyLogFiles,
ILimitPendingWrites writeLimiter = CPendingWriteLimiter::NoLimitLimiter 
)

See base class constructor for details.

CFixedFileHeaderRotatingAsyncFileLog ( const JetByteTools::Core::_tstring filenameBase,
JetByteTools::Core::IQueueTimers timerQueue,
JetByteTools::IO::IIOPool pool,
JetByteTools::IO::IAllocateBuffers allocator,
const JetByteTools::Core::IProvideLocalTime timeProvider,
RotationPeriod  rotationPeriod = Daily,
FirstFileTimestamp  firstFileTimestamp = IncludeTimestampOnFirstFile,
EmptyLogFileHandling  emptyLogFileHandling = PreserveEmptyLogFiles,
ILimitPendingWrites writeLimiter = CPendingWriteLimiter::NoLimitLimiter 
)

See base class constructor for details.

CFixedFileHeaderRotatingAsyncFileLog ( const JetByteTools::Core::_tstring filenameBase,
IHandleFileCreationFailure handler,
JetByteTools::Core::IQueueTimers timerQueue,
JetByteTools::IO::IIOPool pool,
JetByteTools::IO::IAllocateBuffers allocator,
const JetByteTools::Core::IProvideLocalTime timeProvider,
RotationPeriod  rotationPeriod = Daily,
FirstFileTimestamp  firstFileTimestamp = IncludeTimestampOnFirstFile,
EmptyLogFileHandling  emptyLogFileHandling = PreserveEmptyLogFiles,
ILimitPendingWrites writeLimiter = CPendingWriteLimiter::NoLimitLimiter 
)

See base class constructor for details.


Member Function Documentation

void SetLinesToInclude ( IncludeLines  includeLines  )  [override, virtual]

void LogFixedHeaderMessage ( const std::string &  message  )  [override, virtual]

void LogFixedHeaderMessage ( const char *  pString  )  [override, virtual]

void LogFixedHeaderMessage ( const char *  pString,
ILogMessagesWithFixedFileHeader::DataLength  stringLength 
) [override]

void FixedHeaderComplete (  )  [override, virtual]

void LogMessage ( const char *  pString,
ILogMessages::DataLength  stringLength 
) [override]

CAsyncFileWriterEx * OnNewFileWriter ( CAsyncFileWriterEx pWriter  )  [override, protected, virtual]

Reimplemented from CRotatingAsyncFileLog.

virtual void LogFixedHeaderMessage ( const char *  pString,
DataLength  stringLength 
) [pure virtual, inherited]

void SetLogEntryFormat ( DWORD  format  )  [inherited]

void SetMaxFileSize ( __int64  size  )  [inherited]

void SetMaxLines ( size_t  lines  )  [inherited]

void SetNextFileNumber ( DWORD  nextFileNumber  )  [inherited]

void SetCallback ( CAsyncFileWriter::Callback pCallback  )  [inherited]

Allows you to specify an optional callback implementation to receive notifications.

bool PerformWritesOnThisThread (  )  const [inherited]

Returns true if writes are issued directly from the calling thread and false if they are marshalled to the thread pool.

_tstring GetCurrentLogFileName (  )  const [inherited]

Returns the complete file name of the current log, i.e the filename that was set plus the date/time portion that is generated automatically.

void SetThreadIdentifier ( const std::string &  identifier  )  [override, virtual, inherited]

Sets the identifier used in the log for the current thread to the supplied string. The thread identifier defaults to the thread id in the form "XXX: ", the string supplied as an identifier does not need to include the ": " as this will be appended automatically. It can be any string that will help you to identify the thread concerned.

Implements ILogMessages.

void SetThreadIdentifier ( const std::wstring &  identifier  )  [override, virtual, inherited]

Sets the identifier used in the log for the current thread to the supplied string. The thread identifier defaults to the thread id in the form "XXX: ", the string supplied as an identifier does not need to include the ": " as this will be appended automatically. It can be any string that will help you to identify the thread concerned.

Implements ILogMessages.

void SetLogName ( const std::string &  filenameBase  )  [override, virtual, inherited]

Sets the name of the log file using the supplied filenameBase for the base of the log file name; the actual file name is formed as follows: filenameBase-YYYYMMDD-HHMMSS.log. If filenameBase ends with ".log" then this is automatically stripped to leave the actual file name in the form shown above. Note that if the file log was created with includeTimeInFirstFilename set to false then the file name will NOT include the -HHMMSS section. Note that this creates a new log file with the specified name, it does NOT rename the existing log file. All subsequent automatic log file creation will use the newly supplied filenameBase rather than any that was supplied in the constructor.

Implements ILogMessages.

void SetLogName ( const std::wstring &  filenameBase  )  [override, virtual, inherited]

Sets the name of the log file using the supplied filenameBase for the base of the log file name; the actual file name is formed as follows: filenameBase-YYYYMMDD-HHMMSS.log. If filenameBase ends with ".log" then this is automatically stripped to leave the actual file name in the form shown above. Note that if the file log was created with includeTimeInFirstFilename set to false then the file name will NOT include the -HHMMSS section. Note that this creates a new log file with the specified name, it does NOT rename the existing log file. All subsequent automatic log file creation will use the newly supplied filenameBase rather than any that was supplied in the constructor.

Implements ILogMessages.

void LogMessage ( const VectorOfLines messages  )  [override, virtual, inherited]

Logs the message to the log.

Implements ILogMessages.

void LogMessage ( const DequeOfLines messages  )  [override, virtual, inherited]

Logs the message to the log.

Implements ILogMessages.

void LogMessage ( const std::string &  message  )  [override, virtual, inherited]

Logs the message to the log.

Implements ILogMessages.

void LogMessage ( const std::wstring &  message  )  [override, virtual, inherited]

Logs the message to the log.

Implements ILogMessages.

void LogMessage ( const char *  pString  )  [override, virtual, inherited]

Logs the message to the log.

Implements ILogMessages.

void LogMessage ( const wchar_t *  pString  )  [override, virtual, inherited]

Logs the message to the log.

Implements ILogMessages.

void LogMessage ( const char *  pString,
DataLength  stringLength 
) [override, inherited]

Logs the message to the log.

void LogMessage ( const wchar_t *  pString,
DataLength  stringLength 
) [override, inherited]

Logs the message to the log.

virtual void LogMessage ( const char *  pString,
DataLength  stringLength 
) [pure virtual, inherited]

Logs the message to the log. Note that you should manually synchronise access to this function and the various SetLogName calls.

virtual void LogMessage ( const wchar_t *  pString,
DataLength  stringLength 
) [pure virtual, inherited]

Logs the message to the log. Note that you should manually synchronise access to this function and the various SetLogName calls.

HANDLE GetWaitHandle (  )  const [override, inherited]

void Wait (  )  const [override, inherited]

bool Wait ( Milliseconds  timeoutMillis  )  const [override, inherited]

CAsyncFileWriterEx & GetFileWriter (  )  [protected, inherited]


Generated on Sun Sep 12 19:09:24 2021 for The Server Framework - v7.4 by doxygen 1.5.3