Logging class.
More...
#include <Log.hh>
Inherits LDASTools::AL::Thread.
|
| 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...
|
|
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 | IsDetached () const |
| Reports detached state. More...
|
|
thread_type | ParentThread () const |
| Retrieve key for parent thread.
|
|
|
static void | StackSizeDefault (size_t StackSize) |
|
|
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...
|
|
|
static void | cancelCleanup (Thread *Source) |
| Perform cleanup of a cancelled thread. More...
|
|
Logging class.
This is a very simple logging class that is thread safe. It does support seperate debugging levels for each group.
◆ group_type
Type for group.
This is the data type used when referencing parameters representing the group associated with the message.
◆ level_type
Type for level.
This is the data type used when referencing parameters representing the level of message.
◆ stream_type
The stream_type is used to represent the output stream class used to log the messages.
◆ Log()
LDASTools::AL::Log::Log |
( |
const std::string & |
BaseName | ) |
|
Constructor.
- Parameters
-
[in] | BaseName | The 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.
◆ cancelCleanup()
void LDASTools::AL::Thread::cancelCleanup |
( |
Thread * |
Source | ) |
|
|
staticprotectedinherited |
Perform cleanup of a cancelled thread.
- Parameters
-
[in] | Source | The thread being cancelled. |
◆ CancellationCheck()
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] | 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.
- Note
- This call must only be made by a child thread.
◆ CancellationType() [1/2]
Thread::cancel_type LDASTools::AL::Thread::CancellationType |
( |
signal_type & |
Signal | ) |
const |
|
inherited |
Return the type of cancellation.
- Parameters
-
[out] | Signal | Any auxiliary information associated with the cancellation type |
- Returns
- The type of cancellation.
- See also
- cancel_type
◆ CancellationType() [2/2]
void LDASTools::AL::Thread::CancellationType |
( |
cancel_type |
Type, |
|
|
signal_type |
Signal = SignalHandler::SIGNAL_UNKNOWN |
|
) |
| |
|
inherited |
Establiosh the type of cancellation.
- Parameters
-
[in] | Type | The type of cancellation. |
[in] | Signal | Any 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
◆ EntriesMax()
void LDASTools::AL::Log::EntriesMax |
( |
int |
Value | ) |
|
|
inline |
Specify the maximum number of entries per file.
- Parameters
-
[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.
◆ IsCancelled()
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()
bool LDASTools::AL::Thread::IsDetached |
( |
| ) |
const |
|
inherited |
Reports detached state.
- Returns
- Returns true if the thread has been detached, false otherwise
◆ Message()
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] | 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.
◆ 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()
int LDASTools::AL::Thread::spawn |
( |
start_function_type |
StartFunction = (start_function_type)start_routine | ) |
|
|
protectedinherited |
Spawn a new thread.
- Parameters
-
[in] | StartFunction | The 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()
Set the stream to use for output.
- Parameters
-
[in] | Output | Stream to use for output |
◆ Verbosity()
Establish logging level for a given group.
- Parameters
-
[in] | Group | The group for which the logging level is to be modified. |
[in] | Level | The level of debugging to output. |
◆ VerbosityCheck()
Check if the message will be logged.
- Parameters
-
[in] | Group | The group for which to check. |
[in] | Level | The level to check. |
The documentation for this class was generated from the following files: