ldas-tools-al
2.6.5
|
Logging class. More...
#include <Log.hh>
Classes | |
struct | message_queue_entry_type |
Information about a log message. More... | |
class | StreamCBInterface |
Class to handle stream callbacks. More... | |
class | StreamFile |
class | StreamInterface |
Class to handle streaming of messages. More... | |
class | StreamStdErr |
Public Member Functions | |
Log (const std::string &BaseName) | |
Constructor. More... | |
~Log () | |
Destructor. More... | |
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... | |
stream_type | Stream () |
void | Sync () const |
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. More... | |
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... | |
stream_type | Stream () |
void | Sync () const |
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. More... | |
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... | |
stream_type | Stream () |
void | Sync () const |
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... | |
virtual void | Cancel () |
virtual void | Cancel () |
virtual void | Cancel () |
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... | |
void | CancellationEnable (bool Value) |
void | CancellationEnable (bool Value) |
void | CancellationEnable (bool Value) |
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... | |
void | Detach () const |
void | Detach () const |
void | Detach () const |
virtual void | Join () |
virtual void | Join () |
virtual void | Join () |
bool | IsAlive () const |
bool | IsAlive () const |
bool | IsAlive () const |
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... | |
bool | IsParentThread () const |
bool | IsParentThread () const |
bool | IsParentThread () const |
int | Kill (signal_type Signal) const |
int | Kill (signal_type Signal) const |
int | Kill (signal_type Signal) const |
thread_type | ParentThread () const |
Retrieve key for parent thread. More... | |
thread_type | ParentThread () const |
Retrieve key for parent thread. More... | |
thread_type | ParentThread () const |
Retrieve key for parent thread. More... | |
virtual int | Spawn () |
virtual int | Spawn () |
virtual int | Spawn () |
void | SignalCapture (signal_type Sig) |
void | SignalCapture (signal_type Sig) |
void | SignalCapture (signal_type Sig) |
void | SignalIgnore (signal_type Sig) |
void | SignalIgnore (signal_type Sig) |
void | SignalIgnore (signal_type Sig) |
bool | operator== (const Thread &Source) const |
bool | operator== (const Thread &Source) const |
bool | operator== (const Thread &Source) const |
Static Public Member Functions | |
static void | SelfCancellationCheck (const std::string &Header, const char *File, const int Line) |
static void | SelfCancellationCheck (const std::string &Header, const char *File, const int Line) |
static void | SelfCancellationCheck (const std::string &Header, const char *File, const int Line) |
static size_t | StackSizeDefault () |
static void | StackSizeDefault (size_t StackSize) |
static size_t | StackSizeDefault () |
static void | StackSizeDefault (size_t StackSize) |
static size_t | StackSizeDefault () |
static void | StackSizeDefault (size_t StackSize) |
Protected Types | |
typedef void *(* | start_function_type) (void *) |
typedef void *(* | start_function_type) (void *) |
typedef void *(* | start_function_type) (void *) |
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. 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. More... | |
virtual void | onStreamOpen () |
Hook to do additional action when the stream is opened. More... | |
void | purge () |
Flush the output queue. 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... | |
int | spawn (start_function_type StartFunction=(start_function_type) start_routine) |
Spawn a new thread. More... | |
thread_type | threadId () const |
thread_type | threadId () const |
thread_type | threadId () const |
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. More... | |
bool | stream_delete_on_destruct |
Private Types | |
typedef std::queue< message_queue_entry_type > | message_queue_type |
typedef LDASTools::AL::unordered_map< group_type, level_type > | verbose_map_type |
Container type for managing verbosity levels. More... | |
typedef std::queue< message_queue_entry_type > | message_queue_type |
typedef LDASTools::AL::unordered_map< group_type, level_type > | verbose_map_type |
Container type for managing verbosity levels. More... | |
typedef std::queue< message_queue_entry_type > | message_queue_type |
typedef LDASTools::AL::unordered_map< group_type, level_type > | verbose_map_type |
Container type for managing verbosity levels. More... | |
Private Member Functions | |
virtual void | action () |
Output contents of the message queue to the output stream. More... | |
void | flush (bool EveryThing=false) |
Flush all remaining messages to the log file. More... | |
void | write_message (const message_queue_entry_type &MessageInfo) |
Write message to the output stream. More... | |
virtual void | action () |
Output contents of the message queue to the output stream. More... | |
void | flush (bool EveryThing=false) |
Flush all remaining messages to the log file. More... | |
void | write_message (const message_queue_entry_type &MessageInfo) |
Write message to the output stream. More... | |
virtual void | action () |
Output contents of the message queue to the output stream. More... | |
void | flush (bool EveryThing=false) |
Flush all remaining messages to the log file. More... | |
void | write_message (const message_queue_entry_type &MessageInfo) |
Write message to the output stream. More... | |
Private Attributes | |
const std::string | m_base_name |
int | m_entries_max |
message_queue_type | m_message_queue |
Storage for pending message. More... | |
message_queue_type | m_output_queue |
Storage for output message. More... | |
MutexLock::baton_type | m_message_baton |
Protect integrity of the message queue. More... | |
verbose_map_type | m_verbosity |
Keep track of the verbosity of each group. More... | |
Friends | |
class | LogCB |
Logging class.
This is a very simple logging class that is thread safe. It does support seperate debugging levels for each group.
|
inherited |
|
inherited |
|
inherited |
typedef int LDASTools::AL::Log::group_type |
Type for group.
This is the data type used when referencing parameters representing the group associated with the message.
typedef int LDASTools::AL::Log::group_type |
Type for group.
This is the data type used when referencing parameters representing the group associated with the message.
typedef int LDASTools::AL::Log::group_type |
Type for group.
This is the data type used when referencing parameters representing the group associated with the message.
typedef int LDASTools::AL::Log::level_type |
Type for level.
This is the data type used when referencing parameters representing the level of message.
typedef int LDASTools::AL::Log::level_type |
Type for level.
This is the data type used when referencing parameters representing the level of message.
typedef int LDASTools::AL::Log::level_type |
Type for level.
This is the data type used when referencing parameters representing the level of message.
|
private |
The message_queue_type is used to represent the storage class used for the message queue.
|
private |
The message_queue_type is used to represent the storage class used for the message queue.
|
private |
The message_queue_type is used to represent the storage class used for the message queue.
|
inherited |
|
inherited |
|
inherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
typedef boost::shared_ptr< StreamFile > LDASTools::AL::Log::stream_file_type |
typedef boost::shared_ptr< StreamFile > LDASTools::AL::Log::stream_file_type |
typedef boost::shared_ptr< StreamFile > LDASTools::AL::Log::stream_file_type |
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.
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.
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.
|
private |
Container type for managing verbosity levels.
|
private |
Container type for managing verbosity levels.
|
private |
Container type for managing verbosity levels.
|
inherited |
|
inherited |
|
inherited |
LDASTools::AL::Log::Log | ( | const std::string & | BaseName | ) |
Constructor.
[in] | BaseName | The base name to be used for creation of the log file. |
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.
LDASTools::AL::Log::~Log | ( | ) |
Destructor.
LDASTools::AL::Log::Log | ( | const std::string & | BaseName | ) |
Constructor.
[in] | BaseName | The base name to be used for creation of the log file. |
LDASTools::AL::Log::~Log | ( | ) |
Destructor.
LDASTools::AL::Log::Log | ( | const std::string & | BaseName | ) |
Constructor.
[in] | BaseName | The base name to be used for creation of the log file. |
LDASTools::AL::Log::~Log | ( | ) |
Destructor.
|
privatevirtual |
Output contents of the message queue to the output stream.
This method is used for updating the output stream. It is done by a child thread and is started when the object is created. The thread is terminated when the object is destroyed.
Implements LDASTools::AL::Thread.
|
privatevirtual |
Output contents of the message queue to the output stream.
Implements LDASTools::AL::Thread.
|
privatevirtual |
Output contents of the message queue to the output stream.
Implements LDASTools::AL::Thread.
|
virtualinherited |
|
virtualinherited |
|
virtualinherited |
|
staticprotectedinherited |
Perform cleanup of a cancelled thread.
[in] | Source | The thread being cancelled. |
|
staticprotectedinherited |
Perform cleanup of a cancelled thread.
[in] | Source | The thread being cancelled. |
|
staticprotectedinherited |
Perform cleanup of a cancelled thread.
[in] | Source | The thread being cancelled. |
|
inherited |
Deliver pending cancellation requests to the calling thread.
[in] | Header | Description of the method from which the request was made |
[in] | File | Filename from where the request was made. |
[in] | Line | Line 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.
|
inherited |
Deliver pending cancellation requests to the calling thread.
[in] | Header | Description of the method from which the request was made |
[in] | File | Filename from where the request was made. |
[in] | Line | Line number in Filename from where the request was made. |
|
inherited |
Deliver pending cancellation requests to the calling thread.
[in] | Header | Description of the method from which the request was made |
[in] | File | Filename from where the request was made. |
[in] | Line | Line number in Filename from where the request was made. |
|
inherited |
|
inherited |
|
inherited |
|
inherited |
Return the type of cancellation.
[out] | Signal | Any auxiliary information associated with the cancellation type |
|
inherited |
Return the type of cancellation.
[out] | Signal | Any auxiliary information associated with the cancellation type |
|
inherited |
Return the type of cancellation.
[out] | Signal | Any auxiliary information associated with the cancellation type |
|
inherited |
Establiosh the type of cancellation.
[in] | Type | The type of cancellation. |
[in] | Signal | Any auxiliary information associated with the cancellation type. |
Sets a how a thread can be cancelled.
|
inherited |
Establiosh the type of cancellation.
[in] | Type | The type of cancellation. |
[in] | Signal | Any auxiliary information associated with the cancellation type. |
|
inherited |
Establiosh the type of cancellation.
[in] | Type | The type of cancellation. |
[in] | Signal | Any auxiliary information associated with the cancellation type. |
|
inherited |
|
inherited |
|
inherited |
|
inline |
Specify the maximum number of entries per file.
[in] | Value | The number of entries. |
The Value specified is the maximum number of lines that a file should have before triggering a log rotation request.
void LDASTools::AL::Log::EntriesMax | ( | int | Value | ) |
Specify the maximum number of entries per file.
[in] | Value | The number of entries. |
void LDASTools::AL::Log::EntriesMax | ( | int | Value | ) |
Specify the maximum number of entries per file.
[in] | Value | The number of entries. |
|
private |
Flush all remaining messages to the log file.
|
inlineprivate |
Flush all remaining messages to the log file.
|
private |
Flush all remaining messages to the log file.
|
inherited |
|
inherited |
|
inherited |
|
inherited |
Return the cancellation state of the thread.
|
inherited |
Return the cancellation state of the thread.
|
inherited |
Return the cancellation state of the thread.
|
inherited |
Reports detached state.
|
inherited |
Reports detached state.
|
inherited |
Reports detached state.
|
inherited |
|
inherited |
|
inherited |
|
virtualinherited |
|
virtualinherited |
|
virtualinherited |
|
inherited |
|
inherited |
|
inherited |
void LDASTools::AL::Log::Message | ( | const group_type | Group, |
const level_type | Level, | ||
const std::string & | Message | ||
) |
Send a message to the log.
[in] | Group | The group associated with the message. |
[in] | Level | The level associated with the message. |
[in] | Message | The 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.
void LDASTools::AL::Log::Message | ( | const group_type | Group, |
const level_type | Level, | ||
const std::string & | Message | ||
) |
Send a message to the log.
[in] | Group | The group associated with the message. |
[in] | Level | The level associated with the message. |
[in] | Message | The text of the message. |
void LDASTools::AL::Log::Message | ( | const group_type | Group, |
const level_type | Level, | ||
const std::string & | Message | ||
) |
Send a message to the log.
[in] | Group | The group associated with the message. |
[in] | Level | The level associated with the message. |
[in] | Message | The text of the message. |
|
protectedvirtual |
Hook to do additional action when the stream is closed.
|
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.
|
protectedvirtual |
Hook to do additional action when the stream is closed.
|
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.
|
protectedvirtual |
Hook to do additional action when the stream is opened.
|
protectedvirtual |
Hook to do additional action when the stream is opened.
|
inherited |
|
inherited |
|
inherited |
|
inlineinherited |
Retrieve key for parent thread.
|
inherited |
Retrieve key for parent thread.
|
inherited |
Retrieve key for parent thread.
|
protected |
Flush the output queue.
|
protected |
Flush the output queue.
Send all output to the open log file.
|
protected |
Flush the output queue.
|
staticinherited |
|
staticinherited |
|
staticinherited |
|
inherited |
|
inherited |
|
inherited |
|
inherited |
|
inherited |
|
inherited |
|
virtualinherited |
|
virtualinherited |
|
virtualinherited |
|
protectedinherited |
Spawn a new thread.
[in] | StartFunction | The routine for the new thread to start. |
|
protectedinherited |
Spawn a new thread.
[in] | StartFunction | The routine for the new thread to start. |
|
protectedinherited |
Spawn a new thread.
[in] | StartFunction | The routine for the new thread to start. |
|
staticinherited |
|
staticinherited |
|
inlinestaticinherited |
|
staticinherited |
|
staticinherited |
Establish the default value of the stack size used when creating new threads. This routine does validate the requested value..
|
staticinherited |
void LDASTools::AL::Log::Stream | ( | stream_type | Output | ) |
Set the stream to use for output.
[in] | Output | Stream to use for output |
void LDASTools::AL::Log::Stream | ( | stream_type | Output | ) |
Set the stream to use for output.
[in] | Output | Stream to use for output |
void LDASTools::AL::Log::Stream | ( | stream_type | Output | ) |
Set the stream to use for output.
[in] | Output | Stream to use for output |
stream_type LDASTools::AL::Log::Stream | ( | ) |
stream_type LDASTools::AL::Log::Stream | ( | ) |
Log::stream_type LDASTools::AL::Log::Stream | ( | ) |
void LDASTools::AL::Log::Sync | ( | ) | const |
void LDASTools::AL::Log::Sync | ( | ) | const |
void LDASTools::AL::Log::Sync | ( | ) | const |
|
protectedinherited |
|
inlineprotectedinherited |
|
protectedinherited |
void LDASTools::AL::Log::Verbosity | ( | const group_type | Group, |
const level_type | Level | ||
) |
Establish logging level for a given group.
[in] | Group | The group for which the logging level is to be modified. |
[in] | Level | The level of debugging to output. |
void LDASTools::AL::Log::Verbosity | ( | const group_type | Group, |
const level_type | Level | ||
) |
Establish logging level for a given group.
[in] | Group | The group for which the logging level is to be modified. |
[in] | Level | The level of debugging to output. |
|
inline |
Establish logging level for a given group.
[in] | Group | The group for which the logging level is to be modified. |
[in] | Level | The level of debugging to output. |
bool LDASTools::AL::Log::VerbosityCheck | ( | const group_type | Group, |
const level_type | Level | ||
) | const |
Check if the message will be logged.
[in] | Group | The group for which to check. |
[in] | Level | The level to check. |
bool LDASTools::AL::Log::VerbosityCheck | ( | const group_type | Group, |
const level_type | Level | ||
) | const |
Check if the message will be logged.
[in] | Group | The group for which to check. |
[in] | Level | The level to check. |
|
inline |
Check if the message will be logged.
[in] | Group | The group for which to check. |
[in] | Level | The level to check. |
|
private |
Write message to the output stream.
This method does the actual writing of the message to the log.
[in] | MessageInfo | The content to be written to the log. |
|
private |
Write message to the output stream.
[in] | MessageInfo | The content to be written to the log. |
|
private |
Write message to the output stream.
[in] | MessageInfo | The content to be written to the log. |
|
friend |
|
private |
The base name for the log file. It is used as the pattern for log rotation.
|
private |
Holder for the maximum number of entries that should be written to the stream before rotating. If the value is zero, then it is unlimited.
|
mutableprivate |
Protect integrity of the message queue.
The holder of this resouce has the authority to modify the message queue..
|
private |
Storage for pending message.
This storage holds the list of pending mesages.
|
private |
Storage for output message.
This storage holds the list of pending output mesages.
|
protected |
Active output stream.
|
mutableprivate |
Keep track of the verbosity of each group.
|
protected |