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

Inheritance diagram for CAsyncFileLog:

Inheritance graph
[legend]
Collaboration diagram for CAsyncFileLog:

Collaboration graph
[legend]

List of all members.


Detailed Description

A class that implements JetByteTools::Win32::ILogMessages to provide an asynchronous file log that uses overlapped I/O to perform writes to the log file. This class allows you to change the name of the log file after creation but this functionality should be externally synchronised with any use of the various LogMessage() calls and any calls on the IWaitable interface to ensure that SetLogName() is never called concurrently to one of the other calls. The reason that we require YOU to do this synchronisation work is that when used carefully (i.e. SetLogName() is never called when the class is being used by multiple threads) then there is no need to synchronise the calls to LogMessage().

Public Types

typedef unsigned long DataLength

Public Member Functions

 CAsyncFileLog (const JetByteTools::Win32::_tstring &filename)
 Construct an async file log using the supplied filename for the log file. 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.
 CAsyncFileLog (const JetByteTools::Win32::_tstring &filename, JetByteTools::IO::IIOPool &pool, JetByteTools::IO::IAllocateBuffers &allocator)
 Construct an async file log using the supplied filename for the log file. File I/O will be done using the threads in the IIOPool provided and data buffers obtained from the supplied buffer allocator.
 CAsyncFileLog (const JetByteTools::Win32::_tstring &filename, JetByteTools::IO::IIOPool &pool, JetByteTools::IO::IAllocateBuffers &allocator, const JetByteTools::Win32::IProvideLocalTime &timeProvider)
 Construct an async file log using the supplied filename for the log file. File I/O will be done using the threads in the IIOPool provided and data buffers obtained from the supplied buffer allocator.
 ~CAsyncFileLog ()
 Waits for any pending writes to complete and then destroys the log object.
bool PerformWritesOnThisThread () const
 Returns true if writes are issued directly from the calling thread and false if they are marshalled to the thread pool.
virtual void SetThreadIdentifier (const std::string &identifier)
 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.
virtual void SetThreadIdentifier (const std::wstring &identifier)
 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.
virtual void SetLogName (const std::string &logName)
 Sets the name of the log file to the supplied name. Note that this creates a new log file with the specified name, it does NOT rename the existing log file. Note that you should manually synchronise access to this function and the various LogMessage and IWaitable calls.
virtual void SetLogName (const std::wstring &logName)
 Sets the name of the log file to the supplied name. Note that this creates a new log file with the specified name, it does NOT rename the existing log file. Note that you should manually synchronise access to this function and the various LogMessage and IWaitable calls.
virtual void LogMessage (const std::string &message)
 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 std::wstring &message)
 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 char *const pString)
 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 *const pString)
 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 char *const pString, const DataLength stringLength)
 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 *const pString, const DataLength stringLength)
 Logs the message to the log. Note that you should manually synchronise access to this function and the various SetLogName calls.
virtual HANDLE GetWaitHandle () const
 Access a HANDLE to wait on by passing it to one of the Wait Functions.
virtual void Wait () const
 Wait indefinitely for the object to become signalled.
virtual bool Wait (const Milliseconds timeoutMillis) const
 Wait, with a time limit, for the object to become signalled.

Static Public Member Functions

static void Wait (HANDLE handle)
 Wait indefinitely for the supplied handle to become signalled.
static bool Wait (HANDLE handle, const Milliseconds timeout)
 Wait, with a time limit, for the supplied handle to become signalled.
static bool WaitWithMessageLoop (HANDLE handle, const Milliseconds timeout)
static bool WaitWithMessageLoop (HANDLE handle, const Milliseconds timeout, const DWORD removeFlags)
static bool WaitWithMessageLoop (const DWORD numHandles, HANDLE *pHandles, const Milliseconds timeout)
static bool WaitWithMessageLoop (const DWORD numHandles, HANDLE *pHandles, DWORD &signalledHandle, const Milliseconds timeout)
static bool WaitWithMessageLoop (const DWORD numHandles, HANDLE *pHandles, DWORD &signalledHandle, const Milliseconds timeout, const DWORD removeFlags)

Member Typedef Documentation

typedef unsigned long DataLength [inherited]


Constructor & Destructor Documentation

CAsyncFileLog ( const JetByteTools::Win32::_tstring filename  )  [explicit]

Construct an async file log using the supplied filename for the log file. 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.

CAsyncFileLog ( const JetByteTools::Win32::_tstring filename,
JetByteTools::IO::IIOPool pool,
JetByteTools::IO::IAllocateBuffers allocator 
)

Construct an async file log using the supplied filename for the log file. File I/O will be done using the threads in the IIOPool provided and data buffers obtained from the supplied buffer allocator.

CAsyncFileLog ( const JetByteTools::Win32::_tstring filename,
JetByteTools::IO::IIOPool pool,
JetByteTools::IO::IAllocateBuffers allocator,
const JetByteTools::Win32::IProvideLocalTime timeProvider 
)

Construct an async file log using the supplied filename for the log file. File I/O will be done using the threads in the IIOPool provided and data buffers obtained from the supplied buffer allocator.

~CAsyncFileLog (  ) 

Waits for any pending writes to complete and then destroys the log object.


Member Function Documentation

bool PerformWritesOnThisThread (  )  const

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

void SetThreadIdentifier ( const std::string &  identifier  )  [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  )  [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 &  name  )  [virtual]

Sets the name of the log file to the supplied name. Note that this creates a new log file with the specified name, it does NOT rename the existing log file. Note that you should manually synchronise access to this function and the various LogMessage and IWaitable calls.

Implements ILogMessages.

void SetLogName ( const std::wstring &  name  )  [virtual]

Sets the name of the log file to the supplied name. Note that this creates a new log file with the specified name, it does NOT rename the existing log file. Note that you should manually synchronise access to this function and the various LogMessage and IWaitable calls.

Implements ILogMessages.

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

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

Implements ILogMessages.

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

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

Implements ILogMessages.

void LogMessage ( const char *const   pString  )  [virtual]

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

Implements ILogMessages.

void LogMessage ( const wchar_t *const   pString  )  [virtual]

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

Implements ILogMessages.

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

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

Implements ILogMessages.

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

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

Implements ILogMessages.

HANDLE GetWaitHandle (  )  const [virtual]

Access a HANDLE to wait on by passing it to one of the Wait Functions.

Implements IWaitable.

void Wait (  )  const [virtual]

Wait indefinitely for the object to become signalled.

Implements IWaitable.

bool Wait ( const Milliseconds  timeout  )  const [virtual]

Wait, with a time limit, for the object to become signalled.

Implements IWaitable.

void Wait ( HANDLE  handle  )  [static, inherited]

Wait indefinitely for the supplied handle to become signalled.

bool Wait ( HANDLE  handle,
const Milliseconds  timeout 
) [static, inherited]

Wait, with a time limit, for the supplied handle to become signalled.

bool WaitWithMessageLoop ( HANDLE  handle,
const Milliseconds  timeout 
) [static, inherited]

bool WaitWithMessageLoop ( HANDLE  handle,
const Milliseconds  timeout,
const DWORD  removeFlags 
) [static, inherited]

bool WaitWithMessageLoop ( const DWORD  numHandles,
HANDLE *  pHandles,
const Milliseconds  timeout 
) [static, inherited]

bool WaitWithMessageLoop ( const DWORD  numHandles,
HANDLE *  pHandles,
DWORD &  signalledHandle,
const Milliseconds  timeout 
) [static, inherited]

bool WaitWithMessageLoop ( const DWORD  numHandles,
HANDLE *  pHandles,
DWORD &  signalledHandle,
const Milliseconds  timeout,
const DWORD  removeFlags 
) [static, inherited]


Generated on Thu Mar 26 16:39:22 2009 for JetByte Socket Tools - v6.0 by  doxygen 1.5.3