ldas-tools-al  2.6.3
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
LDASTools::AL::Log Class Reference

Logging class. More...

#include <Log.hh>

Inherits LDASTools::AL::Thread, LDASTools::AL::Thread, and LDASTools::AL::Thread.

Classes

struct  message_queue_entry_type
 Information about a log message. More...
 
class  StreamCBInterface
 Class to handle stream callbacks. More...
 
class  StreamInterface
 Class to handle streaming of messages. More...
 

Public Types

typedef int group_type
 Type for group. More...
 
typedef boost::shared_ptr< StreamInterfacestream_type
 
typedef int level_type
 Type for level. More...
 
typedef int group_type
 Type for group. More...
 
typedef boost::shared_ptr< StreamInterfacestream_type
 
typedef int level_type
 Type for level. More...
 
typedef int group_type
 Type for group. More...
 
typedef boost::shared_ptr< StreamInterfacestream_type
 
typedef int level_type
 Type for level. More...
 

Public Member Functions

 Log (const std::string &BaseName)
 Constructor. More...
 
 ~Log ()
 Destructor.
 
void Message (const group_type Group, const level_type Level, const std::string &Message)
 Send a message to the log. More...
 
void Stream (stream_type Output)
 Set the stream to use for output. More...
 
void Verbosity (const group_type Group, const level_type Level)
 Establish logging level for a given group. More...
 
bool VerbosityCheck (const group_type Group, const level_type Level) const
 Check if the message will be logged. More...
 
void EntriesMax (int Value)
 Specify the maximum number of entries per file. More...
 
 Log (const std::string &BaseName)
 Constructor. More...
 
 ~Log ()
 Destructor.
 
void Message (const group_type Group, const level_type Level, const std::string &Message)
 Send a message to the log. More...
 
void Stream (stream_type Output)
 Set the stream to use for output. More...
 
void Verbosity (const group_type Group, const level_type Level)
 Establish logging level for a given group. More...
 
bool VerbosityCheck (const group_type Group, const level_type Level) const
 Check if the message will be logged. More...
 
void EntriesMax (int Value)
 Specify the maximum number of entries per file. More...
 
 Log (const std::string &BaseName)
 Constructor. More...
 
 ~Log ()
 Destructor.
 
void Message (const group_type Group, const level_type Level, const std::string &Message)
 Send a message to the log. More...
 
void Stream (stream_type Output)
 Set the stream to use for output. More...
 
void Verbosity (const group_type Group, const level_type Level)
 Establish logging level for a given group. More...
 
bool VerbosityCheck (const group_type Group, const level_type Level) const
 Check if the message will be logged. More...
 
void EntriesMax (int Value)
 Specify the maximum number of entries per file. More...
 
void CancellationCheck (const std::string &Header, const char *File, const int Line) const
 Deliver pending cancellation requests to the calling thread. More...
 
void CancellationCheck (const std::string &Header, const char *File, const int Line) const
 Deliver pending cancellation requests to the calling thread. More...
 
void CancellationCheck (const std::string &Header, const char *File, const int Line) const
 Deliver pending cancellation requests to the calling thread. More...
 
cancel_type CancellationType (signal_type &Signal) const
 Return the type of cancellation. More...
 
void CancellationType (cancel_type Type, signal_type Signal=SignalHandler::SIGNAL_UNKNOWN)
 Establiosh the type of cancellation. More...
 
cancel_type CancellationType (signal_type &Signal) const
 Return the type of cancellation. More...
 
void CancellationType (cancel_type Type, signal_type Signal=SignalHandler::SIGNAL_UNKNOWN)
 Establiosh the type of cancellation. More...
 
cancel_type CancellationType (signal_type &Signal) const
 Return the type of cancellation. More...
 
void CancellationType (cancel_type Type, signal_type Signal=SignalHandler::SIGNAL_UNKNOWN)
 Establiosh the type of cancellation. More...
 
bool IsCancelled () const
 Return the cancellation state of the thread. More...
 
bool IsCancelled () const
 Return the cancellation state of the thread. More...
 
bool IsCancelled () const
 Return the cancellation state of the thread. More...
 
bool IsDetached () const
 Reports detached state. More...
 
bool IsDetached () const
 Reports detached state. More...
 
bool IsDetached () const
 Reports detached state. More...
 
thread_type ParentThread () const
 Retrieve key for parent thread.
 
thread_type ParentThread () const
 Retrieve key for parent thread.
 
thread_type ParentThread () const
 Retrieve key for parent thread.
 

Static Public Member Functions

static void StackSizeDefault (size_t StackSize)
 

Protected Member Functions

virtual void onStreamClose ()
 Hook to do additional action when the stream is closed. More...
 
virtual void onStreamOpen ()
 Hook to do additional action when the stream is opened. More...
 
void purge ()
 Flush the output queue. More...
 
virtual void onStreamClose ()
 Hook to do additional action when the stream is closed.
 
virtual void onStreamOpen ()
 Hook to do additional action when the stream is opened.
 
void purge ()
 Flush the output queue.
 
virtual void onStreamClose ()
 Hook to do additional action when the stream is closed.
 
virtual void onStreamOpen ()
 Hook to do additional action when the stream is opened.
 
void purge ()
 Flush the output queue.
 
int spawn (start_function_type StartFunction=(start_function_type) start_routine)
 Spawn a new thread. More...
 
int spawn (start_function_type StartFunction=(start_function_type) start_routine)
 Spawn a new thread. More...
 
int spawn (start_function_type StartFunction=(start_function_type) start_routine)
 Spawn a new thread. More...
 

Static Protected Member Functions

static void cancelCleanup (Thread *Source)
 Perform cleanup of a cancelled thread. More...
 
static void cancelCleanup (Thread *Source)
 Perform cleanup of a cancelled thread. More...
 
static void cancelCleanup (Thread *Source)
 Perform cleanup of a cancelled thread. More...
 

Protected Attributes

stream_type m_stream
 Active output stream.
 

Detailed Description

Logging class.

This is a very simple logging class that is thread safe. It does support seperate debugging levels for each group.

Member Typedef Documentation

◆ group_type [1/3]

Type for group.

This is the data type used when referencing parameters representing the group associated with the message.

◆ group_type [2/3]

Type for group.

This is the data type used when referencing parameters representing the group associated with the message.

◆ group_type [3/3]

Type for group.

This is the data type used when referencing parameters representing the group associated with the message.

◆ level_type [1/3]

Type for level.

This is the data type used when referencing parameters representing the level of message.

◆ level_type [2/3]

Type for level.

This is the data type used when referencing parameters representing the level of message.

◆ level_type [3/3]

Type for level.

This is the data type used when referencing parameters representing the level of message.

◆ stream_type [1/3]

typedef boost::shared_ptr< StreamInterface > LDASTools::AL::Log::stream_type

The stream_type is used to represent the output stream class used to log the messages.

◆ stream_type [2/3]

typedef boost::shared_ptr< StreamInterface > LDASTools::AL::Log::stream_type

The stream_type is used to represent the output stream class used to log the messages.

◆ stream_type [3/3]

typedef boost::shared_ptr< StreamInterface > LDASTools::AL::Log::stream_type

The stream_type is used to represent the output stream class used to log the messages.

Constructor & Destructor Documentation

◆ Log() [1/3]

LDASTools::AL::Log::Log ( const std::string &  BaseName)

Constructor.

Parameters
[in]BaseNameThe base name to be used for creation of the log file.
Returns
An instance of this object.

Constructor for the Log class. This will save the base name to use for the log file and start the writing thread.

This class works by seperating the request to log a message and the actual writing of the message. This seperation allows for multiple threads to log messages asyncronously while minimizing the serialization caused by critical resources being locked.

◆ Log() [2/3]

LDASTools::AL::Log::Log ( const std::string &  BaseName)

Constructor.

Parameters
[in]BaseNameThe base name to be used for creation of the log file.
Returns
An instance of this object.

◆ Log() [3/3]

LDASTools::AL::Log::Log ( const std::string &  BaseName)

Constructor.

Parameters
[in]BaseNameThe base name to be used for creation of the log file.
Returns
An instance of this object.

Member Function Documentation

◆ cancelCleanup() [1/3]

void LDASTools::AL::Thread::cancelCleanup ( Thread *  Source)
staticprotectedinherited

Perform cleanup of a cancelled thread.

Parameters
[in]SourceThe thread being cancelled.

◆ cancelCleanup() [2/3]

static void LDASTools::AL::Thread::cancelCleanup ( Thread *  Source)
staticprotectedinherited

Perform cleanup of a cancelled thread.

Parameters
[in]SourceThe thread being cancelled.

◆ cancelCleanup() [3/3]

static void LDASTools::AL::Thread::cancelCleanup ( Thread *  Source)
staticprotectedinherited

Perform cleanup of a cancelled thread.

Parameters
[in]SourceThe thread being cancelled.

◆ CancellationCheck() [1/3]

void LDASTools::AL::Thread::CancellationCheck ( const std::string &  Header,
const char *  File,
const int  Line 
) const
inherited

Deliver pending cancellation requests to the calling thread.

Parameters
[in]HeaderDescription of the method from which the request was made
[in]FileFilename from where the request was made.
[in]LineLine number in Filename from where the request was made.

Deliver any pending cancellation requests to the calling thread. If cancellation is to be done via exception, then a cancellation exception is throw. If not, then a call to the appropriate thread library's cancellation routine is made.

Note
This call must only be made by a child thread.

◆ CancellationCheck() [2/3]

void LDASTools::AL::Thread::CancellationCheck ( const std::string &  Header,
const char *  File,
const int  Line 
) const
inherited

Deliver pending cancellation requests to the calling thread.

Parameters
[in]HeaderDescription of the method from which the request was made
[in]FileFilename from where the request was made.
[in]LineLine number in Filename from where the request was made.

◆ CancellationCheck() [3/3]

void LDASTools::AL::Thread::CancellationCheck ( const std::string &  Header,
const char *  File,
const int  Line 
) const
inherited

Deliver pending cancellation requests to the calling thread.

Parameters
[in]HeaderDescription of the method from which the request was made
[in]FileFilename from where the request was made.
[in]LineLine number in Filename from where the request was made.

◆ CancellationType() [1/6]

cancel_type LDASTools::AL::Thread::CancellationType ( signal_type &  Signal) const
inherited

Return the type of cancellation.

Parameters
[out]SignalAny auxiliary information associated with the cancellation type
Returns
The type of cancellation.
See also
cancel_type

◆ CancellationType() [2/6]

cancel_type LDASTools::AL::Thread::CancellationType ( signal_type &  Signal) const
inherited

Return the type of cancellation.

Parameters
[out]SignalAny auxiliary information associated with the cancellation type
Returns
The type of cancellation.
See also
cancel_type

◆ CancellationType() [3/6]

Thread::cancel_type LDASTools::AL::Thread::CancellationType ( signal_type &  Signal) const
inherited

Return the type of cancellation.

Parameters
[out]SignalAny auxiliary information associated with the cancellation type
Returns
The type of cancellation.
See also
cancel_type

◆ CancellationType() [4/6]

void LDASTools::AL::Thread::CancellationType ( cancel_type  Type,
signal_type  Signal = SignalHandler::SIGNAL_UNKNOWN 
)
inherited

Establiosh the type of cancellation.

Parameters
[in]TypeThe type of cancellation.
[in]SignalAny auxiliary information associated with the cancellation type.

Sets a how a thread can be cancelled.

  • CANCEL_ASYNCHRONOUS A cancellation request is immediated delivered to the thread.
  • CANCEL_DEFERRED A cancellation request is marked pending for the thread and the thread is cancelled when it gets to a system cancellation point or when CancellationCheck is called.
  • CANCEL_EXCEPTION A cancellation request is marked pending for the thread and the thread throws a cancellation exception upon calling CancellationCheck.
Note
This call must only be made by a chivld thread.
See also
CancellationEnable, CancellationCheck

◆ CancellationType() [5/6]

void LDASTools::AL::Thread::CancellationType ( cancel_type  Type,
signal_type  Signal = SignalHandler::SIGNAL_UNKNOWN 
)
inherited

Establiosh the type of cancellation.

Parameters
[in]TypeThe type of cancellation.
[in]SignalAny auxiliary information associated with the cancellation type.

◆ CancellationType() [6/6]

void LDASTools::AL::Thread::CancellationType ( cancel_type  Type,
signal_type  Signal = SignalHandler::SIGNAL_UNKNOWN 
)
inherited

Establiosh the type of cancellation.

Parameters
[in]TypeThe type of cancellation.
[in]SignalAny auxiliary information associated with the cancellation type.

◆ EntriesMax() [1/3]

void LDASTools::AL::Log::EntriesMax ( int  Value)

Specify the maximum number of entries per file.

Parameters
[in]ValueThe number of entries.

◆ EntriesMax() [2/3]

void LDASTools::AL::Log::EntriesMax ( int  Value)
inline

Specify the maximum number of entries per file.

Parameters
[in]ValueThe number of entries.

The Value specified is the maximum number of lines that a file should have before triggering a log rotation request.

◆ EntriesMax() [3/3]

void LDASTools::AL::Log::EntriesMax ( int  Value)

Specify the maximum number of entries per file.

Parameters
[in]ValueThe number of entries.

◆ IsCancelled() [1/3]

bool LDASTools::AL::Thread::IsCancelled ( ) const
inherited

Return the cancellation state of the thread.

Returns
Returns true if the thread has been cancelled, false otherwise.

◆ IsCancelled() [2/3]

bool LDASTools::AL::Thread::IsCancelled ( ) const
inherited

Return the cancellation state of the thread.

Returns
Returns true if the thread has been cancelled, false otherwise.

◆ IsCancelled() [3/3]

bool LDASTools::AL::Thread::IsCancelled ( ) const
inherited

Return the cancellation state of the thread.

Returns
Returns true if the thread has been cancelled, false otherwise.

◆ IsDetached() [1/3]

bool LDASTools::AL::Thread::IsDetached ( ) const
inherited

Reports detached state.

Returns
Returns true if the thread has been detached, false otherwise

◆ IsDetached() [2/3]

bool LDASTools::AL::Thread::IsDetached ( ) const
inherited

Reports detached state.

Returns
Returns true if the thread has been detached, false otherwise

◆ IsDetached() [3/3]

bool LDASTools::AL::Thread::IsDetached ( ) const
inherited

Reports detached state.

Returns
Returns true if the thread has been detached, false otherwise

◆ Message() [1/3]

void LDASTools::AL::Log::Message ( const group_type  Group,
const level_type  Level,
const std::string &  Message 
)

Send a message to the log.

Parameters
[in]GroupThe group associated with the message.
[in]LevelThe level associated with the message.
[in]MessageThe text of the message.

◆ Message() [2/3]

void LDASTools::AL::Log::Message ( const group_type  Group,
const level_type  Level,
const std::string &  Message 
)

Send a message to the log.

Parameters
[in]GroupThe group associated with the message.
[in]LevelThe level associated with the message.
[in]MessageThe text of the message.

◆ Message() [3/3]

void LDASTools::AL::Log::Message ( const group_type  Group,
const level_type  Level,
const std::string &  Message 
)

Send a message to the log.

Parameters
[in]GroupThe group associated with the message.
[in]LevelThe level associated with the message.
[in]MessageThe text of the message.

This member first determins if the Message should be logged based on the Level for the Group. If it should be logged, it will be added to the message queue in a thread safe manner. Another thread is responsible for actually outputting the queue of messages to the log stream.

◆ onStreamClose()

void LDASTools::AL::Log::onStreamClose ( )
protectedvirtual

Hook to do additional action when the stream is closed.

By default, there is no special action that needs to take place when the file is closed.

◆ onStreamOpen()

void LDASTools::AL::Log::onStreamOpen ( )
protectedvirtual

Hook to do additional action when the stream is opened.

By default, there is no special action that needs to take place when the file is opened.

◆ purge()

void LDASTools::AL::Log::purge ( )
protected

Flush the output queue.

Send all output to the open log file.

◆ spawn() [1/3]

int LDASTools::AL::Thread::spawn ( start_function_type  StartFunction = (start_function_type) start_routine)
protectedinherited

Spawn a new thread.

Parameters
[in]StartFunctionThe routine for the new thread to start.

◆ spawn() [2/3]

int LDASTools::AL::Thread::spawn ( start_function_type  StartFunction = (start_function_type) start_routine)
protectedinherited

Spawn a new thread.

Parameters
[in]StartFunctionThe routine for the new thread to start.

◆ spawn() [3/3]

int LDASTools::AL::Thread::spawn ( start_function_type  StartFunction = (start_function_type) start_routine)
protectedinherited

Spawn a new thread.

Parameters
[in]StartFunctionThe routine for the new thread to start.

◆ StackSizeDefault()

void LDASTools::AL::Thread::StackSizeDefault ( size_t  StackSize)
staticinherited

Establish the default value of the stack size used when creating new threads. This routine does validate the requested value..

◆ Stream() [1/3]

void LDASTools::AL::Log::Stream ( stream_type  Output)

Set the stream to use for output.

Parameters
[in]OutputStream to use for output

◆ Stream() [2/3]

void LDASTools::AL::Log::Stream ( stream_type  Output)

Set the stream to use for output.

Parameters
[in]OutputStream to use for output

◆ Stream() [3/3]

void LDASTools::AL::Log::Stream ( stream_type  Output)

Set the stream to use for output.

Parameters
[in]OutputStream to use for output

◆ Verbosity() [1/3]

void LDASTools::AL::Log::Verbosity ( const group_type  Group,
const level_type  Level 
)
inline

Establish logging level for a given group.

Parameters
[in]GroupThe group for which the logging level is to be modified.
[in]LevelThe level of debugging to output.

◆ Verbosity() [2/3]

void LDASTools::AL::Log::Verbosity ( const group_type  Group,
const level_type  Level 
)

Establish logging level for a given group.

Parameters
[in]GroupThe group for which the logging level is to be modified.
[in]LevelThe level of debugging to output.

◆ Verbosity() [3/3]

void LDASTools::AL::Log::Verbosity ( const group_type  Group,
const level_type  Level 
)

Establish logging level for a given group.

Parameters
[in]GroupThe group for which the logging level is to be modified.
[in]LevelThe level of debugging to output.

◆ VerbosityCheck() [1/3]

bool LDASTools::AL::Log::VerbosityCheck ( const group_type  Group,
const level_type  Level 
) const

Check if the message will be logged.

Parameters
[in]GroupThe group for which to check.
[in]LevelThe level to check.

◆ VerbosityCheck() [2/3]

bool LDASTools::AL::Log::VerbosityCheck ( const group_type  Group,
const level_type  Level 
) const
inline

Check if the message will be logged.

Parameters
[in]GroupThe group for which to check.
[in]LevelThe level to check.

◆ VerbosityCheck() [3/3]

bool LDASTools::AL::Log::VerbosityCheck ( const group_type  Group,
const level_type  Level 
) const

Check if the message will be logged.

Parameters
[in]GroupThe group for which to check.
[in]LevelThe level to check.

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