ACE  6.4.2
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
ACE_Log_Category Class Reference

Provides a categorized message logging abstraction. More...

#include <Log_Category.h>

Collaboration diagram for ACE_Log_Category:
Collaboration graph
[legend]

Public Member Functions

 ACE_Log_Category (const char *name)
 
 ~ACE_Log_Category ()
 
unsigned int id ()
 
const char * name ()
 
ACE_Log_Category_TSSper_thr_obj ()
 
u_long priority_mask ()
 Get the process ACE_Log_Priority mask. More...
 
u_long priority_mask (u_long)
 Set the process ACE_Log_Priority mask, returns original mask. More...
 

Static Public Member Functions

static ACE_Log_Categoryace_lib ()
 

Private Member Functions

 ACE_Log_Category (const ACE_Log_Category &)
 
ACE_Log_Categoryoperator= (const ACE_Log_Category &)
 

Private Attributes

const char * name_
 
unsigned int id_
 
u_long priority_mask_
 
ACE_Thread_Mutex keylock_
 Avoid race conditions during initialization. More...
 
ACE_thread_key_t key_
 

Friends

class ACE_Log_Category_TSS
 

Detailed Description

Provides a categorized message logging abstraction.

This class added another level of abstraction to ACE_Log_Msg to separate log messages into different categories. Logs in different categories can be independently enabled or disabled. However, they will all be affected by the priority_mask setting in ACE_Log_Msg. That is to say, if a given priority level is disabled using ACE_Log_Msg::priority_mask(), all messages of that priority level logged via any ACE_Log_Category object would also be disabled regardless of the priority_mask setting in the ACE_Log_Category object.

Each cateogry can have a name which is fixed at construction. The name is not used for formating the messages. However, it can be used by a message backend object for identification and reformat accordingly.

To log a message into a category. Create a new ACE_Log_Category and then use per_thr_obj() for logging. For example,

ACE_Log_Category test_catogory("Test");
test_cateogry.per_thr_obj()->log(LM_DEBUG, "Log into the Test category.");
// set the process wide priority mask
test_catogory.priority_mask(LM_DEBUG|LM_ERROR);
// set the thread specific priority mask
test_cateogry.per_thr_obj()->priority_mask(LM_DEBUG);

Constructor & Destructor Documentation

ACE_Log_Category::ACE_Log_Category ( const char *  name)

Initialize the logger with a name.

Notice that ACE_Log_Category does not deep copy the passed name; therefore, you must keep the lifetime of name longer than the newly create ACE_Log_Category object. The rational for the design is to avoid static initialization problem when the ACE_Log_Category is created in static storage.

Default per-process priority mask By default, all priorities are enabled.

ACE_Log_Category::~ACE_Log_Category ( )
ACE_Log_Category::ACE_Log_Category ( const ACE_Log_Category )
private

Member Function Documentation

ACE_Log_Category & ACE_Log_Category::ace_lib ( )
static
unsigned int ACE_Log_Category::id ( )
inline
const char * ACE_Log_Category::name ( void  )
inline
ACE_Log_Category& ACE_Log_Category::operator= ( const ACE_Log_Category )
private
ACE_Log_Category_TSS * ACE_Log_Category::per_thr_obj ( )
u_long ACE_Log_Category::priority_mask ( )
inline

Get the process ACE_Log_Priority mask.

Get the current ACE_Log_Priority mask.

u_long ACE_Log_Category::priority_mask ( u_long  n_mask)
inline

Set the process ACE_Log_Priority mask, returns original mask.

Set the ACE_Log_Priority mask, returns original mask.

Friends And Related Function Documentation

friend class ACE_Log_Category_TSS
friend

Member Data Documentation

unsigned int ACE_Log_Category::id_
private
ACE_thread_key_t ACE_Log_Category::key_
private

"First time in" flag. Key for the thread-specific error data.

ACE_Thread_Mutex ACE_Log_Category::keylock_
private

Avoid race conditions during initialization.

we couldn't directly use ACE_TSS because it would create circular dependency

const char* ACE_Log_Category::name_
private
u_long ACE_Log_Category::priority_mask_
private

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