Public Types | |
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 | |
CRotatingAsyncFileLog (const JetByteTools::Core::_tstring &filenameBase, RotationPeriod rotationPeriod=Daily, FirstFileTimestamp firstFileTimestamp=IncludeTimestampOnFirstFile, EmptyLogFileHandling emptyLogFileHandling=PreserveEmptyLogFiles, ILimitPendingWrites &writeLimiter=CPendingWriteLimiter::NoLimitLimiter) | |
Construct an async file log 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 firstFileTimestamp can be used to suppress the timestamp, -HHMMSS section, of the first file name generated. Note that emptyLogFileHandling can be used to prevent the creation of empty log files if no logging occurs during a log files activity period. Note that maxPendingWrites can be used to limit the number of pending write operations to prevent uncontrolled 'non paged pool' memory usage if log messages are produced at a rate faster than they can be written to the disk. Note that once the limit is reached all writes become synchronous until the number of pending writes has dropped below the limit again. Timers will be managed with a default timer queue. File I/O will be done using a default I/O thread pool with a single thread and buffers will be allocated from a default allocator with a buffer size of 100 bytes and a pool size of 10. | |
CRotatingAsyncFileLog (const JetByteTools::Core::_tstring &filenameBase, IHandleFileCreationFailure &handler, RotationPeriod rotationPeriod=Daily, FirstFileTimestamp firstFileTimestamp=IncludeTimestampOnFirstFile, EmptyLogFileHandling emptyLogFileHandling=PreserveEmptyLogFiles, ILimitPendingWrites &writeLimiter=CPendingWriteLimiter::NoLimitLimiter) | |
Construct an async file log 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. If creation of any log files fails then the failure handler will be called, this can change the name, wait a while or allow the creation to fail. Note that firstFileTimestamp can be used to suppress the timestamp, -HHMMSS section, of the first file name generated. Note that emptyLogFileHandling can be used to prevent the creation of empty log files if no logging occurs during a log files activity period. Note that maxPendingWrites can be used to limit the number of pending write operations to prevent uncontrolled 'non paged pool' memory usage if log messages are produced at a rate faster than they can be written to the disk. Note that once the limit is reached all writes become synchronous until the number of pending writes has dropped below the limit again. Timers will be managed with a default timer queue. File I/O will be done using a default I/O thread pool with a single thread and buffers will be allocated from a default allocator with a buffer size of 100 bytes and a pool size of 10. | |
CRotatingAsyncFileLog (const JetByteTools::Core::_tstring &filenameBase, JetByteTools::IO::IAllocateBuffers &allocator, IHandleFileCreationFailure &handler, RotationPeriod rotationPeriod=Daily, FirstFileTimestamp firstFileTimestamp=IncludeTimestampOnFirstFile, EmptyLogFileHandling emptyLogFileHandling=PreserveEmptyLogFiles, ILimitPendingWrites &writeLimiter=CPendingWriteLimiter::NoLimitLimiter) | |
Construct an async file log 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. If creation of any log files fails then the failure handler will be called, this can change the name, wait a while or allow the creation to fail. Note that firstFileTimestamp can be used to suppress the timestamp, -HHMMSS section, of the first file name generated. Note that emptyLogFileHandling can be used to prevent the creation of empty log files if no logging occurs during a log files activity period. Note that maxPendingWrites can be used to limit the number of pending write operations to prevent uncontrolled 'non paged pool' memory usage if log messages are produced at a rate faster than they can be written to the disk. Note that once the limit is reached all writes become synchronous until the number of pending writes has dropped below the limit again. Timers will be managed with a default timer queue. File I/O will be done using a default I/O thread pool with a single thread and buffers will be allocated from the supplied allocator. | |
CRotatingAsyncFileLog (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) | |
Construct an async file log 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 firstFileTimestamp can be used to suppress the timestamp, -HHMMSS section, of the first file name generated. Note that emptyLogFileHandling can be used to prevent the creation of empty log files if no logging occurs during a log files activity period. Note that maxPendingWrites can be used to limit the number of pending write operations to prevent uncontrolled 'non paged pool' memory usage if log messages are produced at a rate faster than they can be written to the disk. Note that once the limit is reached all writes become synchronous until the number of pending writes has dropped below the limit again. File I/O will be done using the threads in the IIOPool provided and data buffers obtained from the supplied buffer allocator. | |
CRotatingAsyncFileLog (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) | |
Construct an async file log 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. If creation of any log files fails then the failure handler will be called, this can change the name, wait a while or allow the creation to fail. Note that firstFileTimestamp can be used to suppress the timestamp, -HHMMSS section, of the first file name generated. Note that emptyLogFileHandling can be used to prevent the creation of empty log files if no logging occurs during a log files activity period. Note that maxPendingWrites can be used to limit the number of pending write operations to prevent uncontrolled 'non paged pool' memory usage if log messages are produced at a rate faster than they can be written to the disk. Note that once the limit is reached all writes become synchronous until the number of pending writes has dropped below the limit again. File I/O will be done using the threads in the IIOPool provided and data buffers obtained from the supplied buffer allocator. | |
CRotatingAsyncFileLog (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) | |
Construct an async file log 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 firstFileTimestamp can be used to suppress the timestamp, -HHMMSS section, of the first file name generated. Note that emptyLogFileHandling can be used to prevent the creation of empty log files if no logging occurs during a log files activity period. Note that maxPendingWrites can be used to limit the number of pending write operations to prevent uncontrolled 'non paged pool' memory usage if log messages are produced at a rate faster than they can be written to the disk. Note that once the limit is reached all writes become synchronous until the number of pending writes has dropped below the limit again. File I/O will be done using the threads in the IIOPool provided and data buffers obtained from the supplied buffer allocator. | |
CRotatingAsyncFileLog (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) | |
Construct an async file log 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. If creation of any log files fails then the failure handler will be called, this can change the name, wait a while or allow the creation to fail. Note that firstFileTimestamp can be used to suppress the timestamp, -HHMMSS section, of the first file name generated. Note that emptyLogFileHandling can be used to prevent the creation of empty log files if no logging occurs during a log files activity period. Note that maxPendingWrites can be used to limit the number of pending write operations to prevent uncontrolled 'non paged pool' memory usage if log messages are produced at a rate faster than they can be written to the disk. Note that once the limit is reached all writes become synchronous until the number of pending writes has dropped below the limit again. File I/O will be done using the threads in the IIOPool provided and data buffers obtained from the supplied buffer allocator. | |
CRotatingAsyncFileLog (const CRotatingAsyncFileLog &rhs) | |
~CRotatingAsyncFileLog () override | |
Waits for any pending writes to complete and then destroys the log object. | |
CRotatingAsyncFileLog & | operator= (const CRotatingAsyncFileLog &rhs) |
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. | |
HANDLE | GetWaitHandle () const override |
void | Wait () const override |
bool | Wait (Milliseconds timeoutMillis) const override |
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. | |
Protected Member Functions | |
CAsyncFileWriterEx & | GetFileWriter () |
virtual CAsyncFileWriterEx * | OnNewFileWriter (CAsyncFileWriterEx *pWriter) |
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.
enum RotationPeriod |
enum FirstFileTimestamp |
enum EmptyLogFileHandling |
enum LogEntryFormat |
CRotatingAsyncFileLog | ( | const JetByteTools::Core::_tstring & | filenameBase, | |
RotationPeriod | rotationPeriod = Daily , |
|||
FirstFileTimestamp | firstFileTimestamp = IncludeTimestampOnFirstFile , |
|||
EmptyLogFileHandling | emptyLogFileHandling = PreserveEmptyLogFiles , |
|||
ILimitPendingWrites & | writeLimiter = CPendingWriteLimiter::NoLimitLimiter | |||
) | [explicit] |
Construct an async file log 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 firstFileTimestamp can be used to suppress the timestamp, -HHMMSS section, of the first file name generated. Note that emptyLogFileHandling can be used to prevent the creation of empty log files if no logging occurs during a log files activity period. Note that maxPendingWrites can be used to limit the number of pending write operations to prevent uncontrolled 'non paged pool' memory usage if log messages are produced at a rate faster than they can be written to the disk. Note that once the limit is reached all writes become synchronous until the number of pending writes has dropped below the limit again. Timers will be managed with a default timer queue. File I/O will be done using a default I/O thread pool with a single thread and buffers will be allocated from a default allocator with a buffer size of 100 bytes and a pool size of 10.
CRotatingAsyncFileLog | ( | const JetByteTools::Core::_tstring & | filenameBase, | |
IHandleFileCreationFailure & | handler, | |||
RotationPeriod | rotationPeriod = Daily , |
|||
FirstFileTimestamp | firstFileTimestamp = IncludeTimestampOnFirstFile , |
|||
EmptyLogFileHandling | emptyLogFileHandling = PreserveEmptyLogFiles , |
|||
ILimitPendingWrites & | writeLimiter = CPendingWriteLimiter::NoLimitLimiter | |||
) |
Construct an async file log 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. If creation of any log files fails then the failure handler will be called, this can change the name, wait a while or allow the creation to fail. Note that firstFileTimestamp can be used to suppress the timestamp, -HHMMSS section, of the first file name generated. Note that emptyLogFileHandling can be used to prevent the creation of empty log files if no logging occurs during a log files activity period. Note that maxPendingWrites can be used to limit the number of pending write operations to prevent uncontrolled 'non paged pool' memory usage if log messages are produced at a rate faster than they can be written to the disk. Note that once the limit is reached all writes become synchronous until the number of pending writes has dropped below the limit again. Timers will be managed with a default timer queue. File I/O will be done using a default I/O thread pool with a single thread and buffers will be allocated from a default allocator with a buffer size of 100 bytes and a pool size of 10.
CRotatingAsyncFileLog | ( | const JetByteTools::Core::_tstring & | filenameBase, | |
JetByteTools::IO::IAllocateBuffers & | allocator, | |||
IHandleFileCreationFailure & | handler, | |||
RotationPeriod | rotationPeriod = Daily , |
|||
FirstFileTimestamp | firstFileTimestamp = IncludeTimestampOnFirstFile , |
|||
EmptyLogFileHandling | emptyLogFileHandling = PreserveEmptyLogFiles , |
|||
ILimitPendingWrites & | writeLimiter = CPendingWriteLimiter::NoLimitLimiter | |||
) |
Construct an async file log 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. If creation of any log files fails then the failure handler will be called, this can change the name, wait a while or allow the creation to fail. Note that firstFileTimestamp can be used to suppress the timestamp, -HHMMSS section, of the first file name generated. Note that emptyLogFileHandling can be used to prevent the creation of empty log files if no logging occurs during a log files activity period. Note that maxPendingWrites can be used to limit the number of pending write operations to prevent uncontrolled 'non paged pool' memory usage if log messages are produced at a rate faster than they can be written to the disk. Note that once the limit is reached all writes become synchronous until the number of pending writes has dropped below the limit again. Timers will be managed with a default timer queue. File I/O will be done using a default I/O thread pool with a single thread and buffers will be allocated from the supplied allocator.
CRotatingAsyncFileLog | ( | 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 | |||
) |
Construct an async file log 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 firstFileTimestamp can be used to suppress the timestamp, -HHMMSS section, of the first file name generated. Note that emptyLogFileHandling can be used to prevent the creation of empty log files if no logging occurs during a log files activity period. Note that maxPendingWrites can be used to limit the number of pending write operations to prevent uncontrolled 'non paged pool' memory usage if log messages are produced at a rate faster than they can be written to the disk. Note that once the limit is reached all writes become synchronous until the number of pending writes has dropped below the limit again. File I/O will be done using the threads in the IIOPool provided and data buffers obtained from the supplied buffer allocator.
CRotatingAsyncFileLog | ( | 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 | |||
) |
Construct an async file log 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. If creation of any log files fails then the failure handler will be called, this can change the name, wait a while or allow the creation to fail. Note that firstFileTimestamp can be used to suppress the timestamp, -HHMMSS section, of the first file name generated. Note that emptyLogFileHandling can be used to prevent the creation of empty log files if no logging occurs during a log files activity period. Note that maxPendingWrites can be used to limit the number of pending write operations to prevent uncontrolled 'non paged pool' memory usage if log messages are produced at a rate faster than they can be written to the disk. Note that once the limit is reached all writes become synchronous until the number of pending writes has dropped below the limit again. File I/O will be done using the threads in the IIOPool provided and data buffers obtained from the supplied buffer allocator.
CRotatingAsyncFileLog | ( | 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 | |||
) |
Construct an async file log 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 firstFileTimestamp can be used to suppress the timestamp, -HHMMSS section, of the first file name generated. Note that emptyLogFileHandling can be used to prevent the creation of empty log files if no logging occurs during a log files activity period. Note that maxPendingWrites can be used to limit the number of pending write operations to prevent uncontrolled 'non paged pool' memory usage if log messages are produced at a rate faster than they can be written to the disk. Note that once the limit is reached all writes become synchronous until the number of pending writes has dropped below the limit again. File I/O will be done using the threads in the IIOPool provided and data buffers obtained from the supplied buffer allocator.
CRotatingAsyncFileLog | ( | 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 | |||
) |
Construct an async file log 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. If creation of any log files fails then the failure handler will be called, this can change the name, wait a while or allow the creation to fail. Note that firstFileTimestamp can be used to suppress the timestamp, -HHMMSS section, of the first file name generated. Note that emptyLogFileHandling can be used to prevent the creation of empty log files if no logging occurs during a log files activity period. Note that maxPendingWrites can be used to limit the number of pending write operations to prevent uncontrolled 'non paged pool' memory usage if log messages are produced at a rate faster than they can be written to the disk. Note that once the limit is reached all writes become synchronous until the number of pending writes has dropped below the limit again. File I/O will be done using the threads in the IIOPool provided and data buffers obtained from the supplied buffer allocator.
CRotatingAsyncFileLog | ( | const CRotatingAsyncFileLog & | rhs | ) |
~CRotatingAsyncFileLog | ( | ) | [override] |
Waits for any pending writes to complete and then destroys the log object.
CRotatingAsyncFileLog& operator= | ( | const CRotatingAsyncFileLog & | rhs | ) |
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.
_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, virtual] |
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] |
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] |
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] |
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] |
void LogMessage | ( | const DequeOfLines & | messages | ) | [override, virtual] |
void LogMessage | ( | const std::string & | message | ) | [override, virtual] |
void LogMessage | ( | const std::wstring & | message | ) | [override, virtual] |
void LogMessage | ( | const char * | pString | ) | [override, virtual] |
void LogMessage | ( | const wchar_t * | pString | ) | [override, virtual] |
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.
HANDLE GetWaitHandle | ( | ) | const [override] |
void Wait | ( | ) | const [override] |
bool Wait | ( | Milliseconds | timeoutMillis | ) | const [override] |
CAsyncFileWriterEx & GetFileWriter | ( | ) | [protected] |
CAsyncFileWriterEx * OnNewFileWriter | ( | CAsyncFileWriterEx * | pWriter | ) | [protected, virtual] |
Reimplemented in CFixedFileHeaderRotatingAsyncFileLog.
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.